Backtesting and optimization
What is the best moving average for forex trading? When dealing with the moving averages selecting the optimal length of a moving average can become an issue. In most cases, retail forex traders intuitively select the appropriate length of a moving average. It is crucial to know if the moving average you are using has some statistical edge while testing in the past market data.
Optimization can be done in the market data but over-optimization could only mean curve fitting. In other words, if you over-optimize any price data the backtest results will be fantastic because the moving average is optimized to produce the best results but it is likely to produce very poor results in the future because the future is never like the past.
Optimization and backtesting are two different things. Optimization is finding the best parameter for your indicator and backtesting is the test of how those parameters performed in the different market data. If you want to develop a robust strategy your backtesting should produce consistent results over a wide range of asset classes and time frames.
If you keep on changing your indicator parameter over different time frames and assets that means you are curve fitting the indicator and it is not robust enough to work in all kinds of the market environment.
Timeframes and currency pairs tested
I have not run the optimization of moving averages to find the best periods for the daily time frame on different forex pairs but I arbitrarily chose popular MAs and backtested them to see which gives consistent result over the other.
Simple moving averages of 5-day, 10-day, 20-day, and 50-day have been used in the backtesting. In the backtesting, exchange rate history from January 2000 through Jan 2019 has been used. The currency pairs tested are EURUSD, GBPUSD, USDJPY, AUDUSD, USDCAD, and NZDUSD.
Signals are generated based on End of Day rates. If a buy signal appears at today’s daily closing price, buy trade is executed at that closing price. A buy signal is generated when the price crosses above the moving average and vice versa. Buy and sell trades are simultaneously executed which means the system is always in the market.
Let’s have a look at the backtesting results.
It may be quite surprising and disappointing to know that with 5, 10, 20, and 50 SMA on a daily time frame the best winning rate you can get is only around 32%. However, that is a common thing for a trend-following system.
Trend following strategies is known to cut losses short, letting the profit run. Also, it is believed that market trends only 20-30% of the time, so the majority of the sideways move may have incurred many small losses which resulted in a relatively small win-to-lose ratio.
Among the six moving averages studied, 5, 10, and 20 performed poorly as they were able to profit only in 2 currency pairs. 50-day MA made money in five out of six currency pairs and it gave far superior results than its peer averages.
It should be noted that these moving averages were tested using a very simple trading rule and they were used along with the price. I mean there are various ways to trade using moving averages and they can be combined with other indicators to generate better results.
So, it can be concluded that, although there may be different ways to profit from moving averages-based strategies, the crossover of price and moving average performed poorly in the forex market. Be creative and test your strategy to trade with confidence.