How to set up a Custom Max criterion for fast genetic optimization in MT5?

 

Hi everyone,

I’d like to know how to properly configure a Custom max criterion for the fast genetic-based optimization in MT5.

My goal is to optimize my EA according to the gains and the number of trades, in order to achieve more reliable and consistent results.
When I use the standard “Maximum balance” criterion, I often get configurations showing huge profits but they’re not reliable since the number of trades is extremely low.

As the selected criterion directly affects how the fast genetic algorithm performs its search, I’d like to understand how to customize this criterion (for example, by combining total profit and number of trades) using the Custom max option.

Thanks a lot in advance 

MM

 

There is the built-in complex criterion which is prepared for you by MQ and which includes multiple important metrics at once, so probably you don't need the custom criterion at all.

From my experience a suitable quality is provided by R2-metric, implemented in the algotrading book (RSquared.mqh is available in the code base).

Of course, you can implement it as you wish, say - sqrt(TesterStatistics(STAT_PROFIT)) * sqrt(TesterStatistics(STAT_TRADES)).

MQL5 Book: OnTester event / Trading automation
MQL5 Book: OnTester event / Trading automation
  • www.mql5.com
The OnTester event is generated upon the completion of Expert Advisor testing on historical data (both a separate tester run initiated by the user...