Pine script 这个简单的海龟策略没有职位条目

Pine script 这个简单的海龟策略没有职位条目,pine-script,Pine Script,我试图通过一些调整来测试一个叫做海龟交易系统的策略,但是没有提交任何条目。这个策略基本上有两个系统(短期突破和长期突破),每个都有三个条件 我分别尝试了if语句,甚至应用了条件,但都不起作用。我的代码的逻辑有什么问题吗 //@version=4 strategy("My Strategy", overlay=true, pyramiding=2) //Calculate EMAs emaFast = ema(close, 30) emaSlow = ema(close, 60) emaLon

我试图通过一些调整来测试一个叫做海龟交易系统的策略,但是没有提交任何条目。这个策略基本上有两个系统(短期突破和长期突破),每个都有三个条件

我分别尝试了if语句,甚至应用了条件,但都不起作用。我的代码的逻辑有什么问题吗

//@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")
/@version=4
策略(“我的策略”,叠加=true,聚合=2)
//计算均线
emaFast=ema(关闭,30)
emaSlow=ema(关闭,60)
emaLong=ema(关闭,100)
//确定进入条件
breakoutST=(emaFast>emaSlow)和(close>emaLong)以及(close>high[24])
breakoutLT=(emaFast>emaSlow)和(close>emaLong)以及(close>high[48])
//提交入境令
如果(断开)
strategy.entry(id=“Buy”,long=true)
如果(断开)
strategy.entry(id=“Buy”,long=true)
//退出条件
exitLong1=关闭<低[24]
exitLong2=关闭<低[48]
//退出交易
if(exitLong1)
策略关闭(id=“出售”)
如果(exitLong2)
策略关闭(id=“出售”)

交易应该在两个系统中都发生,我看不到任何交易。你能帮我处理代码吗?

你应该在你的
策略中使用相同的订单id。close()


您应该在
策略中使用与要关闭的订单id相同的。关闭()

// Exit trades
if (exitLong1)
    strategy.close(id="Buy")

if (exitLong2)
    strategy.close(id="Buy")