Which optimization criterion to choose in MT5
Before optimizing, MT5 asks you for a criterion: what it should maximize. It looks like a detail, but it decides which passes you see at the top, which ones are re-tested on the forward and, in a genetic optimization, which combinations get tested at all. This guide explains what each criterion rewards, what it hides and how to choose.
What the criterion does
You choose it in the Settings tab of the Strategy Tester, next to the optimization type. It is the number MT5 uses to score each pass: it appears in the Result column and sets the order of the table. It has three effects:
- The order of the table. What you see at the top is what scores highest on that criterion.
- Which passes go to the forward. With Forward enabled, MT5 uses that criterion to pick the best passes it re-tests, when it does not re-test them all.
- What gets tested, in a genetic search. The algorithm breeds new combinations from those that score high, so the criterion steers the whole exploration. In a complete search everything is tested anyway.
The options and what each one rewards
| Criterion | What it rewards | Its blind spot |
|---|---|---|
| Balance max | The final balance | Ignores the risk taken to get there |
| Profit Factor max | Gross profit relative to gross loss | On its own, a high profit factor can come from very few trades |
| Expected Payoff max | The average profit per trade | Can favor few large trades |
| Drawdown min | The smallest drop | Can favor passes that barely trade |
| Recovery Factor max | Net profit per unit of maximal drawdown | Rests on the single worst drop of the test |
| Sharpe Ratio max | Return relative to its variability | Can favor smooth but tiny returns |
| Complex Criterion max | A 0–100 score combining several metrics | Its exact formula is not published |
| Custom max | Whatever your EA’s OnTester() returns | The easiest one to fit to the result |
The names are those of an English terminal. In older versions of the MT5 help several of these criteria were described combined with the balance (for example “Balance + max Profit Factor”, the product of the balance and the profit factor), and the current menus show the short names. If the exact definition matters to you, check the help of your own terminal (F1), which describes the version you have installed.
Why maximum balance is dangerous
The pass with the most profit is usually the one that risks the most: big lots, distant stops or many trades at once. It can have a drawdown you would never sit through live. If you rank by balance, the top of the list tends to fill up with the passes most exposed to risk and to luck, and with Forward enabled, those are also the ones MT5 sends to the forward.
The complex criterion
It arrived in MT5 build 2615 (2020). It gives each pass a score from 0 to 100 that combines several metrics at once: according to MetaQuotes, the number of trades, the drawdown, the recovery factor, the expected payoff and the Sharpe ratio. In the results table, scores below 20 are shown in red and above 80 in dark green.
It is a reasonable starting point if you have no clear preference, and, because it weighs the drawdown too, a single risky pass finds it harder to top the table than with the balance. Its exact formula has not been published, so treat it as a useful ordering, not as a quality measure you can interpret point by point: a 70 is not “twice as good” as a 35.
The custom criterion
If you code your EA, the OnTester() function runs at the end of each pass and can return any score you like; choose “Custom max” and MT5 will rank by it. Inside it, TesterStatistics() gives you the figures of the pass. For example, this one discards passes with fewer than 100 trades and ranks the rest by recovery factor:
double OnTester()
{
// Fewer than 100 trades: discard the pass
if(TesterStatistics(STAT_TRADES) < 100)
return 0.0;
return TesterStatistics(STAT_RECOVERY_FACTOR);
}
It is the most powerful option and the easiest to overfit: the more you tune the formula until the results look good, the more you are optimizing with your eyes on the result. Write it once, before optimizing, from what you would accept live.
How to choose in practice
- Write down your minimums first: profit factor, maximum drawdown and number of trades you would accept live. Whatever does not meet them is out, whatever the criterion says.
- With a complete search, the criterion matters less: choose one that does not reward profit alone (the complex criterion or the recovery factor) and judge with several metrics.
- With a genetic search, the criterion steers the exploration, so avoid those that reward a single figure: balance alone tends to send the search towards risky zones.
- Keep the criterion you chose. Switching until the table looks the way you expected is another way of optimizing with your eyes on the result.
What to keep in mind
- No criterion prevents overfitting: all of them reward what did well in that period, luck included.
- Always look at several metrics, not just the Result column: a good pass is reasonable in all of them.
- A pass that only shines in the criterion you optimized and falls short in the rest is a warning sign.
Next step
Orometra does not use the Result column to decide: it measures quality with several metrics at once, requires your minimums before ranking anything and looks for plateaus instead of the top of the list. That way, the criterion you chose in MT5 weighs as little as possible on the recommendation.