Optimization Criteria of the Strategy Tester

Optimization Criteria of the Strategy Tester

2 September 2024, 05:18
Daniel Eduardo San Martin
0
34
Welcome!

This post reviews the types and optimization criteria of the Strategy Tester in MetaTrader 5.

OPTIMIZATION OPTIONS

These options can be selected from the menus found in the Settings tab.

Menus

The three optimization options are:

  • Slow complete algorithm
  • Fast genetic-based algorithm
  • All symbols selected in MarketWatch

All symbols... runs the Expert Advisor on different assets. It does so with the parameter configuration we have chosen. It includes all the symbols found in the Market Watch window and sorts the results according to the optimization criteria selected in the second menu, which we will discuss next.

The other two options do not compare assets with each other: they compare different parameter configurations. They do this within certain limits that we set in the "Start," "Step," and "Stop" columns of the Inputs tab.

Colums

The slowest option for this type of optimization tests all possible parameter combinations within the mentioned limits. For each parameter combination, it gets the results of running the Expert Advisor over the evaluated period and presents these results sorted according to the chosen optimization criteria.

In many cases, testing all combinations takes too long. To avoid this, there is the genetic algorithm option.

It helps us find the best values for our Expert's parameters without testing all combinations. Instead, the genetic algorithm discards combinations that don't promise good results and focuses on those considered more promising. It's much faster and yields high-quality results. To use the genetic algorithm, we need to choose an optimization criterion.

OPTIMIZATION CRITERIA

We have eight optimization criteria available. None of these is the best option on its own. A parameter combination with an excellent result in the performance prioritized by each criterion does not imply that the overall performance will be equally good, except for the last of these eight criteria, which combines the performance of your trading system in several aspects.

Balance max

The Balance max criterion looks for the best parameter combination to end the test period with the highest possible balance. The problem with this criterion is that it doesn't take into account the risk taken to achieve it. An Expert Advisor can maximize balance by using high-exposure strategies, but this might result in a higher drawdown than we're willing to tolerate with our real capital.

Profit Factor max

The Profit Factor max criterion aims to maximize the ratio between profits and losses, which could be considered an indicator of the Expert Advisor's efficiency. However, it does not evaluate the frequency of trades, among other factors it doesn't consider. For example, profitability calculated over an insignificant number of trades can be misleading.

Expected Payoff max

This criterion seeks to maximize the average profit per trade. The higher the expected payoff, the more profitable the system is expected to be in the long term. However, this criterion does not consider the variance in profit and loss data, which can translate into elevated risk.

Drawdown min

This criterion focuses on limiting the maximum drawdown. Minimizing drawdown is essential for those looking for low-risk strategies. This criterion is important because it aims to protect capital, which is the trader's main resource, but it may also limit good opportunities.

Recovery Factor max

This criterion seeks to maximize the trading system's ability to recover from losses. It is a good criterion because it balances profitability and risk control since the calculation combines total net profit with maximum drawdown. As with the criteria seen so far, there are other aspects it does not consider. For example, the recovery factor in a backtest with few trades is by no means definitive.

Sharpe Ratio max

This criterion relates profitability to volatility. We use it to achieve a parameter configuration that generates benefits in a stable manner. It is a balanced approach between risk and reward. If we only had the criteria seen so far, this would be the one providing a more comprehensive approach to start evaluating our Expert Advisor.

Custom max

When we select Custom max, the Strategy Tester considers the value of a function implemented in the Expert Advisor's code. We won't consider this possibility now, so let's move on directly to the last one.

Complex Criterion max

This is a comprehensive quality metric that takes several aspects into account at once: the number of trades, drawdown, recovery factor, mathematical expectancy, and the Sharpe ratio.

To be reliable, your trading system must perform well in all these aspects. By choosing Complex Criterion max, the MetaTrader 5 Strategy Tester makes this evaluation for us.

There’s something interesting in the way it returns results, something related to the previous criteria. They are displayed in the "Result" column, and their values are limited between 0 and 100. The values are color-coded based on the strength or weakness of each parameter combination. Acceptable values are shown in green, while insufficient ones are in red. Additionally, the closer to the maximum, the darker the green, and the closer to the minimum, the redder the red.

These colors serve a purpose beyond guiding us in analysis: in the "Result" column of the criteria listed above, we will also find their respective numbers color-coded according to the scale of this complex criterion.

To illustrate with an example: If you use the Balance max criterion and see $100,000 in the Result column, before popping the champagne, check if the number is green as money or red as blood.