该策略是一个基于双均线系统的动量趋势跟踪策略,结合了快速均线与慢速均线的交叉信号,同时引入了过滤均线来优化入场时机,通过资金管理和风险控制,实现稳健的交易效果。
策略采用了11周期和31周期的简单移动平均线(SMA)作为主要信号系统,同时使用5周期均线作为过滤器。当快线(SMA11)上穿慢线(SMA31)且价格位于过滤均线之上时,系统产生做多信号;当快线下穿慢线时,系统平仓。策略通过设定固定的资金量来控制每次交易的规模,从而实现风险管理。
该策略通过多重均线系统构建了一个相对稳健的趋势跟踪系统。虽然存在一些固有的局限性,但通过合理的优化和改进,可以进一步提升策略的稳定性和盈利能力。建议交易者在实盘应用时,结合市场具体情况,对参数进行针对性调整。
/*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)