Orometra

Guide

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 options and what each one rewards

CriterionWhat it rewardsIts blind spot
Balance maxThe final balanceIgnores the risk taken to get there
Profit Factor maxGross profit relative to gross lossOn its own, a high profit factor can come from very few trades
Expected Payoff maxThe average profit per tradeCan favor few large trades
Drawdown minThe smallest dropCan favor passes that barely trade
Recovery Factor maxNet profit per unit of maximal drawdownRests on the single worst drop of the test
Sharpe Ratio maxReturn relative to its variabilityCan favor smooth but tiny returns
Complex Criterion maxA 0–100 score combining several metricsIts exact formula is not published
Custom maxWhatever your EA’s OnTester() returnsThe 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

  1. 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.
  2. 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.
  3. 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.
  4. 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

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.

Analyze my results How Orometra decides →