我制定了三种退出策略,如下所述。第一种是主要的退出策略。二是突破后利润最大化。第三种是只为减少损失。
1. strategy.close( "Long",when = Close_Condition == true and is_breakthrough == false) // main exit strategy
2. strategy.exit("CP","Long", stop = Cut_Profit, when = is_breakthrough == true) // maximize profit strategy
3. strategy.exit("CL","Long", stop = Stop_Price) // cut loss strategy
然而,当整个策略被执行时,**削减损失策略**总是被认为是唯一的退出策略。即使符合策略1或策略2的标准,程序也忽略了这两种策略,并且程序没有采取任何行动(不能出售股票)。
如果删除削减损失策略,则策略1和策略2正常工作,并显示了预期的结果。
那么,如何使这三种退出策略发挥良好的作用呢?任何帮助都将不胜感激。谢谢。
发布于 2019-11-18 10:32:58
这是因为CL
退出总是在maket,所以您不能再发送一个订单来关闭相同的位置。您应该这样做,因此使用strategy.cancel
函数取消以前的订单:
// ...some script's logic...
if is_breakthrough
strategy.cancel("CL") // cancel sent order
strategy.exit("CP","Long", stop = Cut_Profit) opened a new order on position's close
strategy.exit("CL","Long", stop = Stop_Price)
那它应该能起作用
https://stackoverflow.com/questions/58892067
复制相似问题