我正在尝试下 2 个卖单,但我希望根据点值而不是价格获得利润和止损。如果我使用
strategy.exit
,我的止损和利润看起来会是这样,但我不知道如何分割卖出。
strategy.exit("exit", "long", stop = 100, profit = 100)
这可能吗?
shortCondition = close < lowerBand and close[1] > lowerBand
if (shortCondition)
strategy.entry("short", strategy.short, qty=pos_size)
strategy.order("short1", strategy.long, qty=size_trim, comment="closefirst50%")
strategy.order("short2", strategy.long, qty=size_trim, comment="closesecond50%")
longCondition = close > upperBand and close[1] < upperBand
if (longCondition)
strategy.entry("long", strategy.long, qty=pos_size)
strategy.order("long1", strategy.short, qty=size_trim, comment="closefirst50%")
strategy.order("long2", strategy.short, qty=size_trim, comment="closesecond50%")
解决方案是使用2个策略.确实退出
if (shortCondition)
strategy.entry("short", strategy.short, qty=pos_size)
if strategy.position_size < 0
strategy.exit("exit short TP", qty=size_trim, profit = 100, comment="closefirst50%")
strategy.exit("exit short SL", loss = 100, comment="close the remaining 50%")