【发布时间】:2019-06-24 12:08:03
【问题描述】:
我正在尝试在 pine 策略中设置 3 个获利目标。
在下面的代码中,当触发做多条件时,打开一个数量为 100 的条目。这很好。 valueTakeProfit1、2 和 3 的值也是正确的。但是一旦我将它们放入一个 strategy.exit() 中,它们就会被触发或未被触发,或者利润处于错误的水平。 变量 ATR1/2/3percent 的值不是百分比,它只是从通过 strategy.entry() 打开的 100 中取出的数量。
if(longCondition or re_entryCondition)
alertLine := 1
strategy.entry(id="Long Entry", long=true, when=alertLine==1, qty=100)
valueTakeProfit1 := close+ATR1*ma_function(tr(true), lengthATR)
valueTakeProfit2 := close+ATR2*ma_function(tr(true), lengthATR)
valueTakeProfit3 := close+ATR3*ma_function(tr(true), lengthATR)
strategy.exit("Take Profit 1 Long", from_entry="Long Entry", limit=valueTakeProfit1, qty=ATR1percent)
strategy.exit("Take Profit 2 Long", from_entry="Long Entry", limit=valueTakeProfit2, qty=ATR2percent)
strategy.exit("Take Profit 3 Long", from_entry="Long Entry", limit=valueTakeProfit3, qty=ATR3percent)
//End long positions
if(longCloseCondition)
strategy.close(id="Long Entry")
有人可以帮我看看我应该如何定义多个止盈水平吗?
【问题讨论】:
-
使用 strategy.close_all(when=longCloseCondition) 似乎做得更好,但止盈水平是在下一根蜡烛而不是价格达到目标的当前蜡烛上获得的。如何从当前蜡烛中获利?
标签: pine-script