I’ve had similar issues years ago when I first started backtesting similar strategies. Don’t remember details, as I’ve had to solve a lot of problems over time, but I suspect that you’re using historical data that is based on the Open prices that aren’t really relating to MOO orders for those illiquid stocks. Due to low volume those stocks could open 1+ minutes after market opens, and be traded at limit prices/orders, while you get screwed by using market orders. The official opening prices can be based on the first trade, after market opens.
Basically your assumptions may be wrong.
Secondly, it could be due to overfitting, which plagues every trading strategy. That always happens when you tweak your strategy until you get positive results. Though indeed may not happen if you simply try to emulate MOO orders, in which case you’d face other issues like above.