Block"for each trade"Affects backtesting speed
-
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 -
This is one of the side effects of using fxDreema. You can create any EA you want but a t the 'price' of using innefficient loops when bac testing or optimizing. The only solution I found for this iuue over the years is suing fxDreema to confirm my strategy works fine and then hiring a programmer to biuld it from scratch with efficient code. Sorry for the bad news.

-
@TXZZ you've probably already looked into this but is it necessary to process these blocks every tick?
Your EA would be MUCH more efficient if you could process these blocks every M1, M5 or maybe even a higher TF? -

I resolved most of the slowdowns in my EA's on Fxdreema when I started organizing the blocks better, but each person may have a different logic, I'll try to give some tips based on what you mentioned about (orders).
In this case I use the On trade tab and turn on position create and position close blocks to bring me the loops I request, these blocks will act (only when such actions happen).
Just like in Ontick I put the once per bar where the rules or analyzes really need to happen at the candle closes and I only leave in Ontick directly what really needs to be handled at each tick of the market happening, so I believe that fxdreema has its limitations but it is also possible to use the custom mql code block with the help of AI to make things that are slow in fxdreema work faster.