I'm backtesting a strategy and have ExitOnClose set to true. However, some orders are not closed at the end of the day and live through the end of the session and are closed the next day (or sometimes live even longer). I have tested the strategy on 10-min TF so there can be a maximum of 84 bars each day. Some orders have, however, 150, 232 or even more. Please see the attached screenshot.
The parameter ExitOnCloseSeconds seems to be ignored (doesn't have any influence on the backtest) and so is the TimeInForce parameter. The result is always the same.
I'm using the Managed approach, entering Market orders in the OnBarUpdate() method and then attaching Exit limit orders as PTs and Exit stop orders as SLs in the OnExecution() method. The limit and stop orders are canceled at the end of the session but sometimes the market order lives longer.
How is this possible? What am I missing? I'm really desperate because I don't know what's going on and the strategy is completely unusable because of this.
Please help!
Thanks

Comment