Monday, 31 December 2012

Walk Forward Analysis - Holy Grail?

At first I have to worry you: Holy Grail does not exist. Every trading algorithm has its weak points, and will fail under some circumstances. A few examples:
1.      Statistical arbitrage - nowadays, I believe the pricing inefficiencies are captured very quickly by HFT arbitrage strategies used by many funds and proprietary traders. Without exceptionally quick order execution or even exchange collocated hosting I doubt it is possible to be successful in arbitrage in the long term. 
2.       Martingale – obvious.
3.       Trend followers, breakouts, volatility breakouts – look at GBPUSD from second half of 2010. Most of the systems that worked exceptionally well, failed bluntly since then.

I have seen quite a few discussions recently: people try to use walk forward analysis to implement “robustness” into the trading strategies that fall into 3rd point above. Idea is to built in  two opposite trading strategies in one trading system (trend following / counter trade, volatility breakout / volatility retracement) and look for a robust process to choose which one to trade...

Walk Forward Analysis 
Walk Forward Analysis is described here or here. In classical approach, WFA should be used to determine how the profit from a given strategy would change if you would re-optimize the strategy parameters every 1 week, 1 month or 1 year. If you will select a given parameter space for optimization, it will tell you:
  • how good the parameter space is
  • how often you should reoptimize given strategy
  • whether it's not just a local extremum that works for a given system
So in the classical approach you are not influencing the system core - the way in which it trades. But, if you will implement two counter strategies and optimize also the way in which a system trades (trend-following / counter trend), by using the WFA you could potentially find a process that will be flexible enough to detect when the trading mode of the strategy should be switched...  So for example the parameter selection process to use last X bars to optimize the strategy and repeating the optimization every Y days could have been a good way of detecting how the market changed in the past and avoid the system from losing when market changes.


I have spent a lot of time to analyze this for different systems. I used my own implementation of a volatility breakout and trend following system and the following tool to perform the WFA in MetaTrader. The tool is rubbish in my opinion, but for 30 bucks it does what its supposed to. 

Below you can see system results for GBPUSD,  2002-2010:

Being a volatility breakout / trend following system, it obviously failed in 2010 and 2011:


I also implemented a counter trend way of trading into the system and run the WFA to optimize the parameters and the way in which the system trades. Here are the WFA results for 2007, 2008, 2009, 2010 and 2011 (optimization window length of 300 days, and testing window length of 30 days):



The system is able to adapt to periods in which trend following / volatility breakouts works and do not work. If I would decide to re-optimize the strategy every 300 days, I would have a Holy Grail, right? Answer is no. Why? There is no guarantee that the market will change at the same pace in the future. So it might happen that the market will change it's characteristics every few months, and this re-optimization process will just choose the wrong way of trading all the time. 


So is there any value in the WFA?
I believe so and I am using WFA. I re-optimize the volatility breakout and trend following system every 1 month and I use past 10 months to do the optimization. I do it for two reasons:
  • this produces better results than using just one set of parameters that worked throughout the years.
  • if the market will change there is a chance, the system will adapt to these changes. 
However, at some point in time, this process will stop working...