On-close orders

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?

Hi, @backtrader, I find quite a similar question in my case. In fact, I want to invest the OTC fund which I buy and sell at the everyday close price so I have to make decisions based on the current 'predicted' index signal and use the close price of the current bar when it closes.

I read and tried the Docs-Close which says using the close price of the next bar when the next bar actually CLOSES, as well as the Docs-Daysplitter_Close scheme splitting intraday ticks into OHLO and CCCC mentioned by @ab_trader. Finally, both are found not desirable and I didn't find a proper way to implement. Do you have any suggestions?