How to Use Walk Forward Analysis: You May Be Doing It Wrong!

TABLE OF CONTENTS

    Walk Forward Analysis (WFA) is a topic that often generates confusion, especially among novice traders. WFA is a procedure to test the optimization of a trading system and unfortunately, it is often performed incorrectly.

    In this article, we will see how it works, and learn the steps to perform WFA correctly. In addition, we will show you, with a practical example, why this procedure does not fit the Unger MethodTM.

    What Is Walk Forward Analysis

    Walk Forward Analysis begins with testing a trading strategy by finding its optimal parameters over a given timeframe, which is called "in-sample", and verifying the performance of those parameters in the following period, which is called "out-of-sample".

    The objective of the WFA is to determine whether a system is robust enough to maintain its in-sample performance after optimization.

    To give you an example, imagine the WFA as an analysis of a marathon runner’s training. During training, we can analyze performance based on specific parameters, such as speed, endurance, sprint etc.

    Thanks to the performance results obtained in training, we can determine the athlete's level of readiness for competition. So we can, in some way, "predict" his future results.

    The problem is that sometimes the real performance of a trading system is different from that recorded during optimization, just as results during a competition can differ from those obtained in training.

    How Walk Forward Analysis Works

    WFA is used to evaluate the robustness of a trading system.

    To do this, the optimization of specific parameters is done over an in-sample time interval and, subsequently, the behavior of the system is verified in out of sample, that is, in the interval following the optimization.

    Each pair formed by the optimization of in-sample data and the out-of-sample verification represents the so-called “Walk Forward Test” (WFT). The union of all the WFTs up to the most recent historical data constitutes the Walk Forward Analysis.

    In practice, Walk Forward Analysis follows this procedure:

    • Collect essential data (price, volatility, etc.) relating to the market of interest in a given period of time.

    • Divide the time interval into segments called "time windows".

    • Perform the first in-sample optimization on the oldest time segment to find the best parameters.

    • Test these parameters out of sample in the next period.

    • Repeat the operation (in-sample optimization and out-of-sample verification) until you get to the most recent data.

    There is software that allows you to use different parameters such as net profit, drawdown, average trade and profit factor. Some software even allows you to build custom parameters.

    The closer the out-of-sample results are to the in-sample results, the more robust the system.

    Types of Walk Forward Analysis

    There are two types of WFA:

    • Anchored”: The in-sample time window always starts from the beginning of the historical data series and increases progressively

    • "Rolling": The in-sample time window has always the same duration and each one starts after the previous one.

    Generally, for those who use weekly bars, it is advisable to use anchored WFA in order to have a fairly significant historical series of data. For intraday trading models, on the other hand, rolling WFA is more suitable.

    walk foward analysis trading optimization backtest

    Furthermore, the latter method better respects the logic behind the WFA of using what worked most in the last period, while the anchored WFA refers to the entire history.

    In both cases, it is important that the size of the in-sample data is large and accurate enough to predict the behavior of the system in the out-of-sample period, but not too large to avoid noise or false signals.

    WFA and the Efficiency Criterion

    The main criterion used in the WFA to evaluate the optimization of a trading system is an efficiency criterion called Walk Forward Efficiency (WFE).

    The WFE is equal to the ratio between the annualized profit of the out-of-sample and in-sample returns.

    A trading system has a good chance of being profitable when the WFE is greater than 50-60%. When the WFE is lower the trading system is overfitted.

    In addition to profit, it is important to evaluate the behavior of a trading system in the out-of-sample tests also in terms of drawdown, profit factor and average trade.

    The Risk of Overfitting

    Overfitting is, literally, the "excessive adaptation" of a trading system to past data, and represents one of the main mistakes that a trader can run into, especially at the beginning.

    Many traders tend to optimize each parameter on the entire set of past data with the risk, as we explain here of creating a purely illusory system that is capable of adapting very well to the past, but not to future market data.

    In the case of the WFA, overfitting is evident when the excellent backtesting results of optimization are contrasted with poor results in real markets.

    Pros and Cons of the WFA

    One of the greatest advantages of WFA is that it allows for developing trading systems thanks to data collected over long out-of-sample periods. The downside, however, is that this generally leads to very complex scripts.

    Another aspect to consider is that WFA can only be used on trading systems that are based on the use of optimizable parameters.

    The problem is that not all systems use these kinds of parameters. Some strategies open and close positions only when certain market conditions occur and these market conditions may be programmed using numbers and parameters that are not suitable for WFA.

    That is the case with the systems developed using the Unger MethodTM, which are extremely effective at improving the performance of trading systems but are not suitable for this kind of optimization.

    To find out more, we recommend watching the video below where Andrea explains this in further detail:

    Conclusions

    Walk Forward Analysis is a technique for evaluating the robustness and effectiveness of a trading system by comparing in-sample and out-of-sample performances.

    From a theoretical point of view, WFA makes sense. If, in fact, for a specific period of time, certain parameters have worked well, it is likely that they will continue to do so in the next time window.

    Although this approach has positive sides, since it is based on a numerical validation of strategies, its major limitation is that it relies on the use of parameters that need to be suitable for this type of optimization.

    In addition, the danger of overfitting and the complexity of the final codes must also be considered.

    Finally, it is essential to reiterate that the in-sample performance of a strategy never gives any certainty about the future out-of-sample results since real markets are not as predictable. Our advice, therefore, is to carefully evaluate whether this procedure is suitable for your trading approach.