我正在尝试通过一些调整来回溯测试名为Turtle Trading System的策略,但是没有提交任何条目。此策略中基本上有两个系统(短期突破和长期突破),并且分别是三个条件。
我尝试将语句和应用条件分开使用,但没有任何效果。我的代码逻辑是否有问题?
//@version=4
strategy("My Strategy", overlay=true, pyramiding=2)
//Calculate EMAs
emaFast = ema(close, 30)
emaSlow = ema(close, 60)
emaLong = ema(close, 100)
// Determine entry conditions
breakoutST = (emaFast > emaSlow) and (close > emaLong) and (close > high[24])
breakoutLT = (emaFast > emaSlow) and (close > emaLong) and (close > high[48])
// Submit entry orders
if (breakoutST)
strategy.entry(id="Buy", long=true)
if (breakoutLT)
strategy.entry(id="Buy", long=true)
// Exit conditions
exitLong1 = close < low[24]
exitLong2 = close < low[48]
// Exit trades
if (exitLong1)
strategy.close(id="Sell")
if (exitLong2)
strategy.close(id="Sell")
两个系统都应该进行交易,但我看不到任何交易。您能帮我提供代码吗?
答案 0 :(得分:2)
您应该在strategy.close()
中使用要关闭的相同订单ID。
// Exit trades
if (exitLong1)
strategy.close(id="Buy")
if (exitLong2)
strategy.close(id="Buy")