- MetaTrader 5 Built-in Trading Strategy Tester
- MQL5 Wizard: Development of trading robots for MetaTrader 5
- MetaTrader Market - the largest store of trading applications
The best option here would be to return a value on the OnTester function that if it doesn't match a particular criteria (like, if profit factor < X), it returns a bad value so it will not be tested in a forward period.
Imagine you're testing the drawdown. The best possible drawdown is 0 and the worst is -100 (since the tester always thinks the higher the value the better, the worst drawdown must be negative). If you want the tester to start considering only passes with the drawdown better than 20%, you can define a condition on the OnTester function that checks if the drawdown is better than this value or not. If it is better, OnTester returns the original value; if it is not, OnTester returns a bad value (like -100). Doing so makes the tester ignore this pass, since the tester only chooses the some of the best passes to the forward optimization.
Note that in case you use the fast optimization, this alters the way new generations are created (because they're created by analyzing the results of the old ones) and thus may also change the optimization outcome. Use it carefully or with the slow complete algorithm.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use