MT5 Tester built-in genetic algorithm does exactly that (terminates optimization run early, without need for any additional coding).
Hmm.. unfortunately, built-in genetic optimization does not provide a way to customize the early pass termination criteria based on user-defined conditions like max drawdown or max loss.
Built-in algorithm uses its own internal fitness functions and criteria to determine when to terminate an optimization run.
Must admit, genetic algorithm never takes longer than few hours (max number of optimized parameters 16) for 3-5yrs on 1minute OHLC, on decent hardware.
Hmm.. unfortunately, built-in genetic optimization does not provide a way to customize the early pass termination criteria based on user-defined conditions like max drawdown or max loss.
Built-in algorithm uses its own internal fitness functions and criteria to determine when to terminate an optimization run.
Must admit, genetic algorithm never takes longer than few hours (max number of optimized parameters 16) for 3-5yrs on 1minute OHLC, on decent hardware.
Well for me backtest shows 113 hours (on personal laptop using 6 cores) and i am still adding more features to EA which adds more inputs to explore and see if they help optimise the EA. Therefore I am trying to see how i can save time in any way possible.
Hmm.. unfortunately, built-in genetic optimization does not provide a way to customize the early pass termination criteria based on user-defined conditions like max drawdown or max loss.
Built-in algorithm uses its own internal fitness functions and criteria to determine when to terminate an optimization run.
Must admit, genetic algorithm never takes longer than few hours (max number of optimized parameters 16) for 3-5yrs on 1minute OHLC, on decent hardware.
what if, i throw an error if max dd or max loss exceeds certain value, will that prematurely exit those passes and save time as a result?
This is VALID approach, just add max dd as variable.
NOTE: MT5 termination criteria is sufficient already. Focus on your strategy, not logistics.
Many runs will end up in losses , many in profits. When my loss exceeds a certain threshold I wish to stop that run immediately instead of it continuing to execute on the remaining time period left.
This should help me eliminate those useless parameter combinations with large drawdowns as well as reduce the optimization time taken as those runs will be quit early.
How can this be achieved?

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
While performing optimization of input parameters via backtesting feature in metatrader 5, I wish to use some condition to stop the agents run of a particular combination of input parameter early.
On reaching a certain condition while the agent is performing one such run, i wish to quit that run early if certain condition is met. By "quit" I don't mean stop trading (as it will still continue to process rest of the chart period which consumes time), I mean that run should stop altogether and some other parameter combination run should begin.
For example:
For all my input parameters by using fast genetic algorithm, suppose the optimizer shows me that there are 1000000 runs that need to be executed.
Many runs will end up in losses , many in profits. When my loss exceeds a certain threshold I wish to stop that run immediately instead of it continuing to execute on the remaining time period left.
This should help me eliminate those useless parameter combinations with large drawdowns as well as reduce the optimization time taken as those runs will be quit early.
How can this be achieved?
I could not find many topics related to this online.