I'm currently using SetStopLoss() and SetProfitTarget() inside OnBarUpdate, with a delay of one or two candles after the execution is confirmed (execution price captured in OnExecutionUpdate). However, I still experience occasional problems where positions are closed incorrectly, especially during gap openings, and the results are registered as stop losses even when price hasn't touched the stop level.
Is there a more reliable way to structure this logic to ensure the stop/target orders are placed only after a proper confirmation, and avoid these sync issues in live trading?
Thanks in advance for any guidance!

Comment