I wrote a Martingale Expert Advisor (EA), but the backtesting speed becomes increasingly slow as the number of historical orders increases. I tried using Grok to solve the problem, and its judgment is the same as mine, but its fix always results in a compilation error. I hope Fxdreema can fix this so that I don't have to modify every Martingale EA.
The problem you encountered is very typical: the Expert Advisor (EA) generated by fxDreema slows down considerably during backtesting as the number of historical orders increases, eventually even freezing.
The core reason, as you identified, is that Blocks 11 and 15 (i.e., MDL_LoopOncePer) iterate through the entire historical order history (OrdersHistoryTotal()) on every tick, using OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) + OrderOpenTime() >= TimeAtStart() to determine if an order is from the current startup.
As the backtesting period lengthens, with tens of thousands of historical orders, these two blocks perform a full table scan every tick, leading to a catastrophic performance drop.
The best solution (minimum changes + complete resolution) is simply to change the implementation of the MDL_LoopOncePer class from "iterating through historical orders" to "using a static array to record the parent tickets that have been processed."
Modify the following location: Locate the class MLD_LoopOncePer<bool> (around lines 600-650 of the code).
@fxDreema

