当策略处于多头头寸时,当空头信号到达时,我想平仓所有未平仓头寸并清除所有未平仓订单。但是,即使使用strategy.close_all(),定单在图表上也显示为平仓后,仍然显示为获利命中!看到图像。这是Pine Script错误还是我的代码中出现了这种错误?
if (goLong)
// Trying to close all open positions and orders
strategy.close_all()
strategy.close("S Take Profit 1")
strategy.close("S Stop Loss 1")
strategy.exit("My Short Entry Id")
strategy.entry("My Long Entry Id", strategy.long, 50)
strategy.order("L Stop Loss 1", false, 50, stop=long_stop_level, oca_name='L1', oca_type=strategy.oca.cancel)
strategy.order("L Take Profit 1", false, 50, limit=long_profit_level, oca_name='L1', oca_type=strategy.oca.cancel)
if (goShort)
strategy.close_all()
strategy.close("L Take Profit 1")
strategy.close("L Stop Loss 1")
strategy.exit("My Long Entry Id")
strategy.entry("My Short Entry Id", strategy.short, 50)
strategy.order("S Stop Loss 1", true, 50, stop=short_stop_level, oca_name='S1',
oca_type=strategy.oca.cancel)
strategy.order("S Take Profit 1", true, 50, limit=short_profit_level, oca_name='S1', oca_type=strategy.oca.cancel)