//@version=4 strategy(title=“EMA crosses”, overlay=true)
// Inputs priceData = input(title=“Price data”, type=input.source, defval=hl2) ema1Length = input(title=“EMA 1”, type=input.integer, defval=12) ema2Length = input(title=“EMA 2”, type=input.integer, defval=24) ema3Length = input(title=“EMA 3”, type=input.integer, defval=36)
// Compute values ema1 = ta.ema(priceData, ema1Length) ema2 = ta.ema(priceData, ema2Length) ema3 = ta.ema(priceData, ema3Length)
enterLong = ema1 > ema2 and ema2 > ema3 enterShort = ema1 < ema2 and ema2 < ema3
// Plot values plot(series=ema1, color=color.orange, linewidth=2) plot(series=ema2, color=color.maroon, linewidth=2) plot(series=ema3, color=color.blue, linewidth=2)
// Submit orders if (enterLong) strategy.entry(id=“Enter Long”, long=strategy.long)
if (enterShort) strategy.entry(id=“Enter Short”, long=strategy.short)
目前这套代码在回测的时候总是在最开始的时候会下一单,然后其他的似乎就不触发了,哪位大佬可以指导一下怎么让策略循环执行起来呢,感恩。