
Đây là một chiến lược theo dõi xu hướng kết hợp nhiều chỉ số kỹ thuật, chủ yếu là sự phối hợp hợp của ba chỉ số thông qua SMA, MACD và ADX, được giao dịch ở cấp độ vòng tròn. Chiến lược này sử dụng cơ chế dừng lỗ động để tối ưu hóa quản lý rủi ro và kiểm soát vị trí chính xác hơn bằng cách xác định điểm thấp swing.
Lập luận cốt lõi của chiến lược này dựa trên cơ chế xác minh ba lần:
Chiến lược này xây dựng một hệ thống theo dõi xu hướng vững chắc thông qua sự phối hợp của nhiều chỉ số kỹ thuật. Cơ chế dừng động cung cấp kiểm soát rủi ro tốt, phù hợp để theo dõi xu hướng trung và dài hạn. Ưu điểm chính của chiến lược là tín hiệu đáng tin cậy cao, quản lý rủi ro hoàn hảo, nhưng đồng thời cũng phải đối mặt với các thách thức như tín hiệu chậm trễ.
/*backtest
start: 2024-02-20 00:00:00
end: 2024-03-12 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("Invest SMA|MACD|ADX Long Weekly Strategy (BtTL)", overlay=true)
// SMA Inputs
smaLength = input.int(30, title="SMA Länge")
// MACD Inputs
macdFastLength = input.int(9, title="MACD schnelle Periode")
macdSlowLength = input.int(18, title="MACD langsame Perside")
macdSignalLength = input.int(9, title="MACD Signal Smoothing")
//ADX Inputs
adxlen = input(14, title="ADX Smoothing")
dilen = input(14, title="DI Länge")
// SMA-Berechnung
smaValue = ta.sma(close, smaLength)
isAboveSMA = close > smaValue
isBelowSMA = close < smaValue
// MACD-Berechnung
[macdLine, signalLine, _] = ta.macd(close, macdFastLength, macdSlowLength, macdSignalLength)
isMACDBuy = macdLine > signalLine and macdLine > 0
// Swing-Low Berechnung (5-Kerzen)
isSwingLow = low[2] > low[1] and low[3] > low[1] and low[1] < low and low[1] < low[4]
var float lastSwingLow = na
var float secondLastSwingLow = na
// Wenn ein neuer Swing-Low gefunden wird
if (isSwingLow[1])
secondLastSwingLow := lastSwingLow
lastSwingLow := low[1]
//ADX ermitteln
[pDI,mDI,ADX] = ta.dmi(dilen, adxlen)
IsInTrend = ADX > 25
// Einstiegskondition mit MACD und SMA
longCondition = isAboveSMA and isMACDBuy and IsInTrend
if (longCondition)
strategy.entry("Long", strategy.long)
// Ausstiegskondition am vorletzten Swing-Low
if (isBelowSMA and na(secondLastSwingLow) == false)
strategy.exit("Exit", from_entry="Long", stop=secondLastSwingLow)
// Reset bei Position schließen
if(strategy.position_size <= 0)
secondLastSwingLow := na
lastSwingLow := na
// Plots
plot(smaValue, title="SMA 30", color=#063eda, linewidth=2)
plot(na(lastSwingLow) ? na : lastSwingLow, title="Last Swing Low", color=#ffb13b, linewidth=1, style=plot.style_circles)
plot(na(secondLastSwingLow) ? na : secondLastSwingLow, title="Second Last Swing Low", color=color.red, linewidth=1, style=plot.style_circles)