这个简单的乌龟策略没有头寸条目
No position entries for this simple turtle strategy
我正在尝试通过一些调整来回测一种称为海龟交易系统的策略,但没有条目 submitted.There 基本上是该策略中的两个系统(短期突破和长期突破),并且每个条件都有三个条件。
我尝试了 if 语句,甚至分别应用了条件,但是什么都没有 works.Is 我的代码逻辑有什么问题吗?
//@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")
交易应该在两个系统中发生,但我没有看到trades.Could你帮我写代码吗?
您应该在 strategy.close()
.
中使用您想要关闭的 相同的 订单 ID
// Exit trades
if (exitLong1)
strategy.close(id="Buy")
if (exitLong2)
strategy.close(id="Buy")
我正在尝试通过一些调整来回测一种称为海龟交易系统的策略,但没有条目 submitted.There 基本上是该策略中的两个系统(短期突破和长期突破),并且每个条件都有三个条件。
我尝试了 if 语句,甚至分别应用了条件,但是什么都没有 works.Is 我的代码逻辑有什么问题吗?
//@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")
交易应该在两个系统中发生,但我没有看到trades.Could你帮我写代码吗?
您应该在 strategy.close()
.
// Exit trades
if (exitLong1)
strategy.close(id="Buy")
if (exitLong2)
strategy.close(id="Buy")