
Die Strategie ist ein Trend-Tracking-System, das auf mehreren Moving Averages basiert. Sie verwendet einfache Moving Averages mit drei verschiedenen Perioden (z. B. 50, 100, 200) und nutzt eine Kombination aus schnellen und mittleren Durchschnittskursen, um die Trendsicherung in Kombination mit einer schnellen Durchschnittskurse zu nutzen.
Die Kernlogik der Strategie basiert auf den folgenden Schlüsselelementen:
Die Strategie ist ein klassisches Trend-Tracking-System, das durch die kombinierte Verwendung von mehreren Durchschnittslinien sowohl die Zuverlässigkeit der Signale als auch die Fähigkeit, die wichtigsten Trends effektiv zu erfassen, gewährleistet. Obwohl es eine gewisse Rückständigkeit gibt, kann es durch angemessene Optimierung und Risikomanagement zu einem stabilen Handelssystem werden. Die Kernvorteile der Strategie liegen in der Stabilität des Systems und der Klarheit der Operation und eignen sich als Grundlage für den mittelfristigen Trendhandel.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("MA Cross Strategy", overlay=true)
// Input untuk periode Moving Average dan warna label
fastLength = input.int(50, minval=1, title="Fast MA Length")
mediumLength = input.int(100, minval=1, title="Medium MA Length")
slowLength = input.int(200, minval=1, title="Slow MA Length")
longLabelColor = input.color(color.green, "Long Label Color")
shortLabelColor = input.color(color.red, "Short Label Color")
// Hitung Moving Average
fastMA = ta.sma(close, fastLength)
mediumMA = ta.sma(close, mediumLength)
slowMA = ta.sma(close, slowLength)
// Kondisi untuk buy dan sell
longCondition = ta.crossover(fastMA, mediumMA) and close >= slowMA
shortCondition = ta.crossunder(fastMA, mediumMA) and close <= slowMA
// Plot Moving Average
plot(fastMA, color=color.green, linewidth=1, title="Fast MA")
plot(mediumMA, color=color.orange, linewidth=1, title="Medium MA")
plot(slowMA, color=color.red, linewidth=2, title="Slow MA")
// Plot penanda crossover dengan warna dinamis
plot(ta.cross(fastMA, mediumMA) and (longCondition or shortCondition) ? mediumMA : na,
color=longCondition ? color.green : color.red,
style=plot.style_circles, linewidth=4, title="Crossover")
// Plot label saat kondisi entry terpenuhi
plotshape(longCondition, title="Long", location=location.belowbar, style=shape.labelup, size=size.normal, color=color.green, textcolor=color.white, text="Long")
plotshape(shortCondition, title="Short", location=location.abovebar, style=shape.labeldown, size=size.normal, color=color.red, textcolor=color.white, text="Short")
// Strategi
if longCondition
strategy.entry("Long", strategy.long)
if shortCondition
strategy.entry("Short", strategy.short)
// Exit strategy (berdasarkan crossover MA)
if ta.crossunder(fastMA, mediumMA) and strategy.position_size > 0
strategy.close("Long")
if ta.crossover(fastMA, mediumMA) and strategy.position_size < 0
strategy.close("Short")