This strategy is a trend following system based on multiple moving averages. It utilizes three Simple Moving Averages (SMA) with different periods (50, 100, 200) to capture trending opportunities through crossover signals between the fast and medium MAs, combined with trend confirmation from the slow MA. The strategy design aligns with classic trend following principles, enhancing signal reliability through multi-timeframe moving average combinations.
The core logic is based on the following key elements:
This strategy represents a classic trend following system that ensures signal reliability and effective trend capture through multiple moving averages. While it has inherent lag, proper optimization and risk management can make it a robust trading system. Its core strengths lie in system stability and operational clarity, making it suitable as a foundation for medium to long-term trend trading.
/*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")