此简单的乌龟策略无位置条目

问题描述 投票:0回答:1

我正在尝试通过一些调整对称为Turtle Trading System的策略进行回测,但是没有提交任何条目。此策略中基本上有两个系统(短期突破和长期突破),每个都有三个条件。

我尝试了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")

两个系统中都应该进行交易,但我看不到任何交易。您能帮我提供代码吗?

pine-script
1个回答
0
投票

您应该在strategy.close()中使用要关闭的相同订单ID。

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

if (exitLong2)
    strategy.close(id="Buy")
© www.soinside.com 2019 - 2024. All rights reserved.