Home Forex Forex Education How to Optimize a Trading Strategy

How to Optimize a Trading Strategy



Once the developer successfully ends both the multi-market and multiperiod test of a trading strategy, he can move to the optimization process. However, there are some risks associated with its execution that the developer should recognize.

In this educational article, we’ll present the different stages of a trading strategy’s optimization process.

Preparing for the Optimization

After passing the multimarket and multiperiod test, the developer has verified that the trading strategy works. Therefore, he could move toward the next stage that corresponds to the trading strategy optimization.

Optimization is used to determine the optimal parameters for the best result of a specific process. In terms of trading strategy, the optimization corresponds to selecting the most robust parameter set of a strategy that would provide the peak performance in real-time markets. 

Nevertheless, selecting the highest performance that provides the most robust set of parameters can result in challenging work. This situation occurs because each set of parameters will correspond to a specific historical data range used in each simulation.

In this regard, the developer’s top parameter selection must be part of a set of evaluation criteria defined before executing the optimization process.

Risks in Optimization

The optimization has pitfalls that the developer must consider at the time of its execution; these traps can lead to increased risks when applying the trading strategy.

The first risk is overconfidence that the results obtained during optimization will produce the same market results in real-time. The developer must understand the strategy and each effect of the results obtained in each part of the optimization stage.

The second risk involves excessive overfitting of the strategy’s parameters. This risk is due to the execution of the optimization without considering the guidelines and appropriate statistical procedures.

Finally, using a wide range of parameters can lead to obtaining extremely positive backtested results. However, such positive returns generated during the optimization stage do not guarantee that they will happen in real-time markets.

Optimizing a Trading Strategy in MT4

In a previous educational article, we presented the development process of a trading strategy based on the crossings of two moving averages, which corresponds to a linear weighted moving average (LWMA) of 5 periods and a simple moving average (SMA) of 55 periods. 

This example considers the execution of an optimization corresponding to both moving averages, and the optimization’s objective will be to find the highest profit.

Before executing the optimization, the developer must select the Strategy Tester located in the toolbar, as illustrated in the next figure.

Once picked the trading strategy to optimize, it must select “Expert Properties,” where the developer will identify and define the parameters to optimize.

The next figure illustrates the “Expert Properties” box. In the first tab, the developer will select the Testing properties, where the “Custom” option will provide a broad range of outputs for each scenario obtained during the simulation stage. 

After the Testing selection criteria, the developer can select the parameters to optimize during the historical simulation. In the example, the parameters to optimize will be the fast (LWMA(5)) and the slow (SMA(55)) moving averages. The developer must consider that as long as it increases the parameters to optimize simultaneously, the simulation will increase its length of time.

Once the “Start” button is pressed, the Strategy Tester in the “Optimization Results” tab will reveal each parameter variation’s output. In the case illustrated in the following figure, the results are listed from the most to less profitable. 

The results also expose the Total Trades, Profit Factor Expected Payoff, Drawdown ($), and Drawdown (%), and the inputs for each historical simulation.

In conclusion, the trading strategy based on the cross between LWMA(6) and SMA(192) in the historical simulation returned $1,818 of profits with a Drawdown equivalent to 5.77% or $688.17. Likewise, these parameters are valid only for a 4-hour chart. 

Nevertheless, analyzing the criteria described by Robert Pardo, which considers that a trading strategy should provide three times the drawdown, the strategy should generate three times the dropdown, in this case, the parameters applied into the model returned 2.64 times more profits over the drawdown. 

Next Tasks After the First Optimization

Once the first optimization was performed, the developer should analyze the trading strategy behavior with non-correlated assets and its performance in other timeframes. 

If the strategy passes this stage, the developer could make a walk-forward analysis. Among other questions, the strategist should answer whether the strategy will make money in real-time trading.  He also should evaluate the strategy’s robustness, where he would determine if the strategy is sufficiently robust and ready to trade in real-time.

Finally, once these stages are successfully passed, the trading strategy should be tested with paper money before its implementation in the real market.


In this educational article, we presented the steps for executing a simple optimization corresponding to a trading strategy based on the cross between two moving averages.

Before starting to optimize a trading strategy, the developer must weigh both the risks involved by the optimization process and the optimization analysis’s objective as the results that the study will generate.

Finally, although the optimization process reveals that the trading strategy is robust, the developer must continue evaluating if it can generate real-time trading profits.

Suggested Readings

  • Jaekle, U., Tomasini, E.; Trading Systems: A New Approach to System Development and Portfolio Optimisation; Harriman House Ltd.; 1st Edition (2009).
  • Pardo, R.; The Evaluation and Optimization of Trading Strategies; John Wiley & Sons; 2nd Edition (2008).


Please enter your comment!
Please enter your name here