This strategy is a momentum trend following system based on dual moving averages, combining crossover signals from fast and slow moving averages with a filter line to optimize entry timing, achieving stable trading results through proper money management and risk control.
The strategy employs 11-period and 31-period Simple Moving Averages (SMA) as the main signal system, with a 5-period moving average as a filter. Long entry signals are generated when the fast line (SMA11) crosses above the slow line (SMA31) and price is above the filter average. Positions are closed when the fast line crosses below the slow line. The strategy implements risk management through fixed position sizing.
The strategy builds a relatively robust trend following system through multiple moving averages. While it has some inherent limitations, stability and profitability can be further enhanced through appropriate optimization and improvements. Traders are advised to adjust parameters based on specific market conditions when implementing the strategy in live trading.
/*backtest start: 2024-10-01 00:00:00 end: 2024-10-31 23:59:59 period: 3h basePeriod: 3h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy('Nifty 30m SMA Crossover Long', overlay=true) start = timestamp(2020, 1, 1, 0, 0) end = timestamp(2024, 12, 31, 0, 0) SlowSma = ta.sma(close, 31) FastSma = ta.sma(close, 11) FilterSma = ta.sma(close, 5) plot(SlowSma, title='Sma 31', color=color.new(color.green, 0)) plot(FastSma, title='Sma 11', color=color.new(color.red, 0)) plot(FilterSma, title='Filter Sma 5', color=color.new(color.black, 0)) // strategy LongEntry = FastSma > SlowSma and close > FilterSma LongExit = FastSma < SlowSma MyQty = 10000000 / close // // Plot signals to chart // plotshape(not LongExit and strategy.position_size > 0 and bIndicator, title='Hold', location=location.abovebar, color=color.new(color.blue, 0), style=shape.square, text='Hold', textcolor=color.new(color.blue, 0)) // plotshape(LongExit and bIndicator and strategy.position_size > 0, title='Exit', location=location.belowbar, color=color.new(color.red, 0), style=shape.triangledown, text='Sell', textcolor=color.new(color.red, 0)) // plotshape(LongEntry and strategy.position_size == 0 and bIndicator, '', shape.arrowup, location.abovebar, color.new(color.green, 0), text='Buy', textcolor=color.new(color.green, 0)) // plotshape(not LongEntry and strategy.position_size == 0 and bIndicator, '', shape.circle, location.belowbar, color.new(color.yellow, 0), text='Wait', textcolor=color.new(color.black, 0)) if time >= start and time < end strategy.entry('Enter Long', strategy.long, qty=1, when=LongEntry) strategy.close('Enter Long', when=LongExit)