ExitLong/ExitShort ignored when using ExitLongStopMarket/ExitLongLimit in backtest with AddDataSeries

Hi,

I have a multi-timeframe strategy using AddDataSeries for a secondary timeframe. I’m trying to combine:

  1. ExitLongStopMarket / ExitLongLimit for SL/TP (submitted from OnExecutionUpdate with real fill price)
  2. ExitLong / ExitShort for signal-based exits (cancelling SL/TP orders first)

Problems:

  • ExitLongStopMarket / ExitLongLimit from OnExecutionUpdate appear silently ignored in backtest — no errors, positions just don’t close by SL/TP
  • If I use SetStopLoss/SetProfitTarget instead, the signal-based ExitLong calls are then ignored (Internal Order Handling Rules)

Questions:

  1. Can ExitLongStopMarket / ExitLongLimit be used in backtest with Calculate.OnBarClose?
  2. What is the correct approach to have both SL/TP orders AND signal-based exits working simultaneously in backtest with AddDataSeries?

Thank you.

does it work in market replay?

Hi, thanks for the reply, in the end I made it work. Solved.