Before starting to talk about the optimization of a trading system, it is important that you know what these systems are based on or why work with them. In order not to make this article infumable, I leave you this post about what it is and how to create a trading strategy. Once you understand this, you can start looking for tests and optimization ways to get better results.
In this article I am going to tell you about one of the most popular trading tests that exist today. This is the walk forward test.
Optimizing a trading system
We have all asked ourselves the question of what optimization is. The optimization of a trading system is based on the study of a history of premises or past events. This is done with the aim of obtaining a number or close values to consider our profitable system.
In other words, it is based on carrying out a pertinent study about the best results that have occurred in the past, seeking to obtain a range of possible positive results for the market in which one is working.
Since the optimization is based on finding the possible numbers or values that are close to or similar to the possible current values, it is necessary to take into account that prior market information or valid premises must be available.

When you want to make a optimization of some trading system, it is necessary to take into account the type of objective function with which you are working. This is because, for each type of objective function, its values are different.
The objective function with which you are working can be seen framed in any of the ratios to evaluate systems. All these ratios are based on different ways of working, from here arises the difference between the values that can be granted. For example, an objective function may be that the system has the maximum possible net profit or the minimum possible loss. Depending on this, the parameters of our system may be different.
the backtest
This word is very important when optimizing a trading system, since its result will depend on the trading optimization study. In short, doing a backtest is carrying out and evaluating a history of operations. If you don’t know what a backtest is and its importance, this article can help you.
With this, you get a hit percentage, the amount of drawdown or net profit, among others. These data are used as results to introduce future parameters, seeking to obtain a profit.

The backtest is necessary to perform it with certain variants. The more variants that arise, the more backtest you will have to do, until you find a closed resultbut you have to be very careful with overoptimization.
What is overoptimizing a strategy?
In an optimization of a trading system, the possible values that can be generated in the future are sought. This is done by evaluating a previous history and a series of previous variants. Over optimization is playing with marked cards. It is setting the parameters for the best past results.
When many backtests are performed, the result is closer to a point of non-existent perfection. That is, a point where there are no failures or margins of error. When this happens, it is due to a saturation of the variants.
This saturation is called over-optimization. It is one of the factors to which great care must be taken when optimizing a trading system. Since, when you over-optimize a system, the perfect result is nothing more than a big error in values.
To avoid getting over-optimized, it is recommended that you do an optimization with few parameters to optimize. By entering too many parameters, you can fall into over optimization. In my case, in fact, I try not to optimize anything.
What is Walk Forward optimization?
This is one of the most robust optimization systems currently in existence. This is because it performs a full optimization, but a bit late and complex.
Thanks to the fact that its system is a bit complex, if you have a considerable history, its results can be numerous. In other words, the more history you have, the more results you can get.
What makes Walk Forward so good, if it gives numerous results? Walk Forward is considered to be one of the most robust optimizers since it optimizes using historical intervals.
This number of results can be reduced. However, you must be careful not to over optimize.
The optimization through the Walk forward system is carried out by analyzing short intervals in the history of market operations.
That is, when there is a 10-year history, for example, the first three years (1, 2 and 3) of history are taken, they are optimized and the backtest is obtained.

After this, it is taken from the last year of the first optimization, up to the following two years, this including the first backtest. That is, in the second optimization, years 3, 4 and 5 would be taken, together with the first backtest.
This will be done with all the following years until you get the last backtest. Which will be the result of a continuous optimization among all the history.
This constant and iterative optimization is what is considered as the Walk Forward and, thanks to its level of complexity, it is considered one of the most robust. However, it usually gives very accurate results, within the margin of error.
For what purpose is walk forward optimization used in trading systems?
The function with which this type of optimization is carried out is based on the verification of the system for the future. In the same way, you can implement it to obtain possible values that generate a profit.
All this is done with a series of premises. That is, you must do it with a history of operations. By doing so, you can get an idea about the market in the future.
In this way, you will be able to see if it can be productive to apply the trading strategy that you are evaluating. In some cases, you will see that the profitability of the system or the ratio is only temporary.
In short, we can use walk forward to:
- Find the best combination of parameters at each moment of time.
- Measure the robustness of our trading system: we see how it behaves with different parameters.
☑️ Correct optimization
As you already know, you should avoid over-optimization, since this only generates losses. One of the points that you should look at when optimizing a trading system is to avoid unique or isolated values. A result with very good results but lonely, has a lot of risk.
Imagine that you create a strategy based on a 20-period average that works perfectly. But when you look at his results with an average of 19 or 21 it is a complete disaster. Doesn’t sound very reliable does it?
I do not mean by this that your trading strategy will work well with any parameter you use. But what we are looking for are robust systems and if any sensible change causes the results to change abruptly, what we have is not a robust system.
You should keep in mind that the market can make drastic and sudden changes. For this reason, it is recommended that you carry out several optimizations at considerable intervals of time.
This way you ensure that the values obtained the first time remain constant. If not, the market may have made a change and you must adhere to that change.
walk forward matrix
The walk forward matrix is an extended version of the walk forward. I explain.
When we walk forward we do it with a % of oos and spins, here we can make these two parameters move in a range. So that? To have more system data and find the best possible combination (where the system is more robust).
What happens if we choose long optimizations:
+ It is easier to achieve statistical validity.
+ There are a greater number of operations within the same window.
– Selection of parameters based on a wide range of market conditions. Therefore, the chosen parameters are not optimal for current market conditions.
What happens if we choose short optimizations:
– It is more difficult to achieve statistical validity.
– There are fewer operations within the same window.
+ Parameter selection based on current market conditions. Therefore, the chosen parameters will surely be more effective when changing the window and in real, which is what we want.
How to find the midpoint
There are two things we can select:
- The data fractions or how many times we divide the data sample.
- The percentage of OOS.
For both things we choose a range in order to find the most robust parameters.

Two key ratios
There are two ratios that will help us measure whether our trading strategy is robust by applying the walk forward matrix:
➡️ WF stability
Measures how the part of the execution with respect to the optimizedin percentage terms.
The net gain (WF stability) tells us how much the strategy is gaining in OOS (execution) relative to IS (optimization).
Above 100% indicates that the strategy performs better in OOS than optimization, below 100% the opposite.
➡️ WF Score
Measures the percentage value of how much improved optimization compared to the original strategy.
Above 100% the strategy has better results in Walk-Forward than in the original strategy.

How to use the walk forward test?
In my case I do not use it to optimize my trading systems. I use it as a test for assess its robustnesssince when we apply it we are looking at different periods outside the sample.
In this way we obtain more information on how it may behave in the future and the consistency of the strategy. In the end, as you can see, it is about having the chances in our favor with winning strategies and what this test does is provide us with information about our strategies. As I always say, don’t look for perfect strategies, look for real strategies.
I recommend that you take a look at the test and if it is useful to you, incorporate it into your methodology. For me it is one of those tests that is worth it together with the one in Monte Carlo.
Doubts? Comments? I read you! And you know… be careful not to over-optimize.