Walk Forward analysis in Forex trading


Walk Forward analysis in trading is highly appreciated.

Walk forward analysis is what we are going to talk about in this article.   It is known as well as Walk Forward optimization or Walk Forward validation. But the base word is Walk Forward, and I will show you what that means.

The Walk forward analysis is included in the EA Studio strategy builder that we use in the Academy. We have the optimizer which works pretty similar to the optimizer in Meta Trader but works much faster, and I will show it to you right now. So the optimizer finds better parameters for the strategy, and you can normally see on the balance chart the old balance line in a grey color, and you can see how the parameters are changing.

We have the range, the minimum and the maximum, and we have the step. Now, when we are optimizing a strategy, there is a risk to over-optimize the strategy. This means that the Expert Advisor Studio might find better parameters for the indicators, but they will be precisely for this period.

Walk Forward is a tool to prove over-optimization

If we run a strategy after that on Meta Trader, it might show losses. So this is why we either use round steps for optimization like 5 or 10 or 20, or we use the other robust tools like the Walk Forward validation, the Monte Carlo, and the Multi Market.

The Expert Advisor Studio can work on different tabs simultaneously. So you can open it in another tab and run the generator there. Or if you want to run the generator for a couple of currencies, you can do this simultaneously but on different browsers, on separate tabs.

Walk Forward analysis.
The optimizer

After you are done with the optimizer, you can click on edit if you want to use the new parameters… So it’s like you will accept the new parameters.

Out of Sample is what the Walk Forward analysis uses.

If you go to the Walk Forward in the EA Studio, you will see its quite different from the optimizer. So here, what we see are different segments. 1, 2, 3, 4, 5. We have five segments.

And on the right side, you have the Out of Sample Net profit. And you can see that the primary outcome is; in the first segment it makes a profit, in the second one it loses, then a small profit in the third one. The fourth one, the last one lose. OK?

Now, what is the idea of the Walk Forward analysis?

This is the whole back-tested period that we have. And if we select to use 30% Out of Sample, it will divide this entire period into different segments.

And the first one will be 70%, and then this one will be 30%. So we can say the first segment is from this point over here, from the beginning till the end of this green line or to the second vertical line. In 70% of this period, it will optimize the strategy, and for the rest of 30%, for this period it will perform simulated trading.

Out of Sample.
The Equity chart in the Walk Forward Optimization

The idea behind Walk Forward analysis.

This is precisely what I have explained about the Out of Sample. So it’s making Out of Sample but not for the whole period, just for this zone over here for the first segment. After that, it takes the parameters that result from this optimization, and including this period where we had simulated trading, it performs new optimization.

This is the optimization period for the second segment. And then it will simulate trading for the next zone, for this period, for the second green line.

After that same thing repeats. It will add this period, and it will do optimization for this period over here, and it will simulate trading for the next segment. And this repeats till the end.

Now, what is the basic idea of having the Walk Forward analysis? It is to recognize the over-optimized strategy. So this strategy is the initial strategy that was generated.

The over-optimized strategy is what we need to be scared of.

And we want to know if this strategy is over-optimized for this period or not. If it is robust enough to use it in the future. Now, the Walk Forward analysis performs optimization for one period then it simulates trading. It includes the next period to the previous one, performs optimization, and simulates trading for the next one.

And this repeats till the end. Now, if the Walk Forward fails to find better parameters, this gives us a sign that the initial strategy might be over-optimized. Because it shows the result for the complete backtest. If the Walk Forward analysis fails to show a better result, this means that the parameters of the initial strategy were over-optimized.

So let me run now the Walk Forward, and you will see how it works. It will start to optimize the strategy for the first segment, and then it will simulate trading for this zone over here between the first vertical and the second vertical line. And if I go to the parameters, you can see that I have here the original settings.

Walk Forward analysis.
The parameters.

What green and red symbolize.

I can see the parameters of the first segment, and you can see that the RVI signal changed to 17. It’s green because it is just 1 point higher than the initial value. And then, the commodity channel index or the CCI changed the period and as well the level.

So the period is bigger, that’s why it’s in green. And the level is smaller, that’s why it is red. And when it is ready with the first segment, it shows the second one, and it is optimizing again. Going back to the equity chart, I can see here that the simulated trading shows worse results from the initial strategy.

So the original is $103 of profit, and we have just $11 of profit. And then, for the second segment, it shows a positive result of 9. And this is better because the initial strategy during this period has a negative of 16.

Walk Forward analysis update.

This way, we will see at the end if we will have a better strategy or not. Also, in the end, the Walk Forward analysis will show us what is the result of the complete backtest with the new parameters. The parameters from the last segment.

This is something new with the Walk Forward in EA Studio. It was updated in the middle of 2019. This is why I decided to include it in this course. It’s pretty exciting and useful for me. It’s just another way to find a better strategy, and you will see why.

So if I continue with the test, it will reach the fourth segment, and here, only the period of CCI changed 1 point lower than the previous one. So one more time, to summarize it, what it does:

Walk Forward analysis optimizes one period and then simulates trading for the next one. Then it includes this period to the previous and not to the whole last period.

You can see the whole period is divided by five, and in each segment, we have 70% for optimization and 30% to perform simulated trading. And let’s have a look at the parameters. These are the parameters for the last period and is just completing the backtest.

So now, we have different values from the beginning. These are the original values that we have. The Stop Loss and the Take Profit were not changed because in settings, I did not select to optimize the Stop Loss and the Take Profit.

The RVI signal was changed. The level was changed too, and then we have the CCI from 43 to 72 and from -197 to -219. So after it is ready, the Walk Forward performs a complete backtest. And you can see that I have a better strategy than the original one, even at the beginning and in the middle it is going worse.

So this one here is the new strategy after the Walk Forward optimization. And with the gray color is the original one. But in the end, the new strategy makes more profit. So we can say that this strategy is better. Here in the full backtest validation, it says “is strategy better; yes,” it is.

Validation is what determines if the strategy is applicable

As a validation, I just selected a minimum Net profit of $10. So if it is just profitable with a minimal profit like $10, the Strategy Builder takes it as validated.

Minimum Net profit.
The validation columns.

And something exciting here is that the complete backtest or the full backtest with the last parameters is as well with the Out of Sample, which means that it is validated with the Acceptance criteria as well. This is 1.1 Profit factor for the complete backtest and 1.1 for the In Sample and for the Out of Sample.

And this is very important because if we don’t have that, then the strategy might be profiting at the beginning, then losing. Or it could be the case that it will be losing in the Out of Sample part, which is just the recent historical data. But in this way we filter the strategy in such a way, so it shows us a profit at the end of the test as well or at the recent 30% of the test.

What to do if we get a worse strategy?

Let me now do the very same thing with the other strategy that I generated. It has a much better equity line, so I am very interested to see what will be the result there.

And now, I will be starting the Walk Forward analysis tool,  and it will begin to optimize the strategies again for each segment. It will perform simulated trading, then it will add this period. It will perform simulated trading again, and till the end.

And here are the results. What I see is that we have a worse strategy this time. The backtest with the final parameters shows a worse outcome than the initial strategy.

So this is the difference, and I’m glad that I generated these two strategies so you will see the difference. And on the picture below, you can see “is strategy better; no.” This means that the initial strategy made more profit, and the standard Acceptance criteria are not validated as well.

A strategy that does not pass the Walk Forward analysis is most probably over-optimized.

The previous strategy, as well here, was not valid. But “is strategy better” was yes and it was green.

Walk Forward analysis.
The parameters.

To say that the strategy passes the Walk Forward optimization, it needs to have three things:

  • One is the strategy to be better, which is not right here.
  • Second is the standard Acceptance criteria to be validated again is not valid with the strategy.
  • Third, to have all segments validated. And here we have all of the them green, but they don’t make a profit of $10.

This is what we said is the validation, minimum Net profit of 10. So this strategy did not pass the validation in any of the three criteria.

And now, to compare it with the equity chart of the different segments, we can see that the Walk Forward succeeded in making a better equity line. But this is the result of the Walk Forward when it’s optimizing one segment, testing the strategy for the next one, then adding the data and testing it till the end. And we have a better strategy here, so this gives us a sign that the strategy is not over-optimized.

If you have any questions feel free to ask in the Forum.

But in parameters, we see that with the last inputs of the indicators, the strategy made worse results than the original strategy. And if it was the other way round, if the new strategy with the last parameters passed the validation from the Walk Forward, I will see here the green edit button. And the other tool to recognize the over-optimized strategies is the Monte Carlo.

So if I click on the initial strategy, I can perform a Monte Carlo test. I will explain this in detail in some of my other lectures.

If you have any questions about the Walk Forward analysis, don’t hesitate to write in our Forum for the same. Thanks for reading.

Cheers.