I want to test an intraday strategy that involves close positions at the close of each day. Interactive brokers have a type of order to achieve this: Market-on-Close (MOC) Orders. Reading the documentation of backtrader it seems that it doesn't have this feature in backtest mode.
From a point o view, it will not consider appropriate to ask a question while rising a solution because it could induce bias but I will make an exception looking for feedback of my approach in case no other possible solution arrives:
To achieve this kind of behavior I thought to modify my data feed to include two additional bars after the last bar of the day (16:00:00). One will be at 16:00:01 to create a market order and the other one will be at 16:00:02 to execute the order. Both will have in the OHLC data the close price of the 16:00:00 bar.
I'm not simply close my positions at 15:49:00 (supposing minute bars) in order to be executed at 16:00 because I'm not using time bars. So, I have uncertainty about at what time it will be the previous bar to the close of the day.
Could you think in another way to incorporate (or simulate) on-close orders in backtesting with backtrader? Or could you share an inconvenience that you see in my approach?