我的止损似乎只在蜡烛收盘时执行。由于它基于低/高,因此一旦出现高/低就执行是合理的。有没有可能做到这一点?
// Determine stop loss price
lowest(exit_slow)
slowLC = lowest(10)
slowSC = lowest(10)
longStopPrice2 = slowLC[1]
shortStopPrice2 = slowSC[1]
//exit long
if (strategy.position_size > 0) //and not (notcapitulation and momentumL and choppyL)
strategy.exit(id="StopLimit", stop=longStopPrice2, comment="CLOSE", alert_message="STOP")//CloseComment CloseCommentAlert
strategyClose := true
//exit short
if (strategy.position_size < 0)
strategy.exit(id="StopLimit", stop=shortStopPrice2, comment="CLOSE", alert_message="STOP")
strategyClose := true
我当然不想使用未来的数据,所以回测仍然有效。
目前当我查看回测订单时,即使是 STOP 订单也恰好在 4 小时收盘时间执行。