Warning: Declaration of ElementorPro\Modules\Posts\Skins\Skin_Content_Base::register_controls(Elementor\Widget_Base $widget) should be compatible with Elementor\Controls_Stack::register_controls() in /home/customer/www/backtest-rookies.com/public_html/wp-content/plugins/elementor-pro/modules/theme-builder/widgets/post-content.php on line 17
A series of 349 tests have been performed across 4 markets over a 12 year period to determine how well a simple moving average crossover strategy performs longterm. Generally, the best-performing settings across all markets had longer look back periods for the slower moving average in the pair. Conversely, the best settings for faster SMA was approximately 4 times shorter. Finally, the crossover strategy was largely profitable even under sub optimal parameter combinations. The only exception to this was in the GBPUSD. Read on for the full review.
Moving averages are probably one of the most wildly known indicators around. Both simple and informative, they form the basis of many trend following strategies. Furthermore, when price approaches a key moving average level, it often commands the attention of many traders. Although simple in nature, moving averages do come in a couple of flavors. Additionally, interpreting them in a stategy ruleset also often differs. With that in mind, this post is going to focus on the simple moving average when applied in a crossover strategy.
The review also forms part of my series to test and compare Backtrader’s library of built-in indicators. For the series introduction, some notes on the test methodology and results summary table see here: https://backtest-rookies.com/2017/07/31/backtraders-best-forex-indicators/
Note: Results below do not reflect real world performance. As mentioned in the introduction and overview post (linked above), no commissions, leverage or margin are used during testing. The purpose of these tests are to compare the indicators to one and another where all other factors are equal. For more information on how all indicator reviews will be performed, please click on the link above.
Understanding The Simple Moving Average
Simple Moving Averages (SMA’s) are one of the easiest technical indicators to wrap our heads around. If you remember enough math to calculate a basic average, then you understand the SMA. In a nutshell, for every single closed bar we calculate the average closing price for a fixed number of bars in the past (otherwise known as the look back period). The moving part comes in to play because we limit the number of bars in the calculation and new bars are being formed all the time. I.e When a new candle is closed, the candle at the end of the range is pushed out and the newly closed candle goes in. Thus making the average move with price.
In this review, we will be looking using two simple moving averages, one of which has a longer look back period than the other. A longer the look back period means that each new value (candle) does not have as much of an effect on the calculated average. This causes the SMA value to appear to move slower as the look back period increases. Consequently, it is this difference in speed that we will use to generate crossover signals for the strategy (when one SMA value crossover up or down through the other.
Using crossover signals means the test strategy will be very simple:
- Enter short when the faster SMA crosses down through the slower SMA
- Enter long when the faster SMA crosses up through the slower SMA
- Close a short when the faster SMA crosses up through the slower SMA
- Close a long when the faster SMA crosses down through the slower SMA
In addition to the entry criteria, it is worth mentioning that the strategy aims to always be in the market. Therefore, when we close a long or short, we will immediately open another position.
Optimization was performed for the following ranges:
|Fast SMA(s)||Slow SMA|
|5, 6, 7, 8||14|
|5, 6, 7, 8, 9, 10, 11, 12, 13, 14||21|
|5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19||30|
|5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30, 35, 40, 45||50|
|10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90||100|
|20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 100, 120, 140, 160, 180||200|
|50, 60, 70, 80, 100, 120, 140, 160, 180, 200||300|
Initially, I performed optimization of both SMA’s independently and simply optimized them with a large range each. However, I quickly noticed that if I do that some tests would never take a trade. Since Backtrader loops through each and every combination of values, some optimization tests would result in both SMA values being the same. Another issue is that half of the tests performed would effectively reverse the strategy. This is because at some point, what was once the fast SMA would become the slow SMA and vice versa causing the entry/exit criteria to reverse. All this would amount to a set of results where the zero’s skew the averages and the worst settings are simply the opposite of the best settings. Therefore I decided to forcibly keep one SMA’s look back period higher than the other during testing. It results in fewer tests, but I think overall it will provide better insights.
Simple Moving Average Review Results
Overall 349 tests were performed across all four markets and look back periods. Drawdowns ranged from 1.75% to 4.6% with an average drawdown across all tests at 1.96%. Strike rates, on the other hand, were more spread out (18% – 64%). Interestingly, at 2.2%, the test with a strike rate of just 18% did not have the largest drawdown. This is because it took significantly fewer trades over the test period. Perhaps this was to be expected with some of the longer look back periods used.
A summary, gallery of charts and series of statistic tables for each test method are below. The tables give an overview of the best parameter settings for each market along with the best / worst settings across all markets.
Overall winner and loser
|Market||PnL||12 Year Return (%)||Total Trades||Total Won||Total Lost||Strike Rate||Biggest Winner||Biggest Loser||Avg Winner||Avg Loser||Max Drawdown (%)||2005 (% gain/loss)||2006 (% gain/loss)||2007 (% gain/loss)||2008 (% gain/loss)||2009 (% gain/loss)||2010 (% gain/loss)||2011 (% gain/loss)||2012 (% gain/loss)||2013 (% gain/loss)||2014 (% gain/loss)||2015 (% gain/loss)||2016 (% gain/loss)|
|NZDUSD 70, 100||360.94||3.61||42||23||19||54.76||148.97||-47.23||27.61||-14.43||1.75||0.34||0.89||-0.14||1.23||1.4||-0.12||-0.61||-0.47||0.12||0.13||0.72||0.2|
|NZDUSD 12, 21||-442.56||-4.43||208||69||139||33.17||55.37||-34.89||12.95||-9.61||4.6||-0.6||0.53||-0.66||-0.27||-0.52||-0.45||-0.87||0.2||-0.63||-0.37||-0.15||-0.73|
You will see shortly that the best overall parameter settings in the most favorable market (NZDUSD) used fairly similar settings to the best overall parameters by average in all markets.
PnL Curves, 12-Year returns and Stike Rates
The gallery below shows 3 different charts:
- The 12-year annual returns of the best and worst performing tests
- The PnL when altering the fast SMA against the Slow SMA
- The best, worst and average strike rates across all tests.
Almost amazingly when looking at the PnL curves for the fast SMA periods vs the 200 MA, you could have had almost any setting (except in the GBPUSD) and still not lost money! Having said that, the general performance does drop as the period for the fast SMA’s lengthen. This is to be expected in my view because when you have 2 long SMA periods, you have very little current market information. Consequently, this leads me to believe some of the profitable results where both SMA’s had a large look back period (e.g 160 and 200 period test) may have been lucky.
A full copy of the test results in CSV format can be found here: SMA Review results CSV
Best Settings for Each Market
|Market||SMA 1 (Fast)||SMA 2 (Slow)||PnL|
Interestingly here the absolute best settings for the AUDUSD were 16 and 30. This goes against the general trend. Furthermore, reducing the fast SMA by just 2 to 14/30 reduced the profit by almost half which suggests those settings may have hit a sweet spot for that particular market rather than a good general choice.
The GBPUSD also faired a little better to quicker settings and at 17 / 50. However, these are closer to the popular 20/50 combination. Another point worth mentioning is that the actual PnL achieved was not high in comparison to other indicators.
Default Settings Performance
Usually this section would contain defaults settings performance. However, since this strategy requires two indicators and crossover signals, the default settings would be the same for each SMA! Therefore, we would see a crossover. As such, I decided to use the 50 and 200 SMA’s to represent a “default” since this is one of the most common combinations for trend followers
Best / Worst Settings On Average Across All Markets
This table shows the performance of the best and worst settings when the performance was averaged over all the markets under test.
|PnL||Param 1||Param 2|
As we can see, longer look back periods for the slower moving average (200) tend to provide more consistent results when coupled with a faster SMA period of 40. This is not far off the popular 50/200 setting (which in itself performed well). The worst settings have a slow moving average period of 21. This is actually quite fast and suggests the SMA’s may have been prone to whipsawing. (ranging markets where the moving averages are crossing over frequently)
Until next time
Thats all for now, I will try to follow this up with another review soon.
Reference: Best Forex Indicators Comparison
Find This Post Useful?
If this post saved you time and effort, please consider support the site! There are many ways to support us and some won’t even cost you a penny.