Category Archives: Moving Average Setups
On Wednesday, May 15th, $SPY closed 3.52% above its 20 day moving average. While this has happened more than 275 times over the history of $SPY, it is not an altogether common occurrence. It is the first time this has happened in 2013, and it did not happen at all in 2012. A quick glance at the list of these events appeared to show some clustering.
So what happens next? Let’s take a look at what happens over the next 50 days.
- Buy $SPY at the Close when it Closes > 3.5% Above its 20 Day Moving Average
- Sell X Days Later
- All $SPY history used
- No Commissions or Slippage included
While there were 275 occurrences, if we instead look at trades, there were 169 trades held for 1 day and 35 trades held for the full 50 days. This means that there is some clustering occurring. It also means that the further we go out towards 50 days, the more volatile results become, simply because there are fewer trades to average together.
The graph shows that this setup is neutral to slightly bearish. The return is no where near to matching a buy-n-hold return over the same time period. In fact, the return after this setup is about half of what we’d expect after holding $SPY for 50 days.
With $SPY having closed 10 days in a row above its upper Bollinger Band (50,2), many traders are expecting some consolidation. Others are calling for a fairly serious pullback. These results show that in the past, consolidation has been much more likely than a serious pullback.
The 50 day moving average is important in that it calculates the intermediate trend of any given financial instrument. A close beneath it means that we watch to see if the intermediate trend is slowing. Multiple closes beneath the average likely means the intermediate trend is not only slowing but in danger of rolling over and becoming a down trend.
So today’s close beneath the 50 day moving average could be very important, or not. In this case, it is really not that important.
The reason it is not that big of a deal is because the S&P 500 had been trading above its 50 day moving average for 74 days, before closing beneath it. 74 days above the 50 day average means the trend has been strong. Yes, it is likely now slowing, but we shouldn’t expect for the momentum that has been built up over those 74 days to come to a crashing halt.
Perhaps a visual would better demonstrate what we should expect to occur…
- Buy $SPX at the close after it has traded above its 50 day moving average for at least 74 days and then closes beneath it.
- Sell $SPX at the close X days later.
- First $SPX trade is on 12.7.1928.
- No commissions or slippage included.
This setup has tended to generate almost double the average return of buy and hold over a 50 day time frame.
And sample size, while not huge, should be large enough for the results to be considered reliable. There were 38 trades made (add one more for the trade made today), and all of them were able to be held the full 50 days. 74.36% of those trades were higher than the purchase price, 50 days later.
The buy-n-hold results were generated by cutting all $SPX data into 50 day segments and then averaging all of those segments.
The Bottom Line:
Momentum is powerful. It does not typically just stop overnight. While I believe the current trend is slowing and we are likely to see a correction, there is still time to adjust. Trends do not turn off and on like a light switch, yet we often use moving averages to turn off and on our trading strategies.
The simplest ideas are often some of the best. This is a mantra that should often be repeated by traders and investors. The simplest ideas persistently produce profits for long periods of time. I don’t know if this is because they are so simple that they are ignored or because they identify and exploit the structural architecture of markets.
With that thought in mind, I was recently reading a newer blog, Don’t Talk About Your Stocks. This gentleman wants to trade trend following systems but is relatively new to backtesting and system trading. I can identify. I have a keen memory of where I was and what I was doing when I first read Covel’s Trend Following. Similarly, deciding that I would no longer trade discretionary patterns but would instead follow quantifiable, rules based strategies, was a defining moment in my development as a trader, investor, and system designer/tester.
So the SPY 10/100 System is his first attempt at following a rule-based, quantifiable, trend following system. The only problem is that he can’t backtest it. That is a huge handicap, as it certainly stinks to have to paper trade a system for a few years before realizing that it would have worked or didn’t work. Because I like simple ideas and because I can absolutely identify with his desire, I am going to backtest it for him.
We shared a few tweets and I was able to discern the rules for the SPY 10/100 System.
- Buy SPY at the next open after the 10 day simple moving average closes above the 100 day simple moving average
- Sell SPY a the next open after the 10 day simple moving average closes beneath the 100 day simple moving average
I have not included any commissions or slippage. All SPY history was used for this test.
Upon first glance, the equity curve and drawdowns both look promising. It fared well during the Armageddon trade of 2008 but has missed some of the rally from 2011 to the present.
Let’s dig deeper into the system’s statistics:
The 5.73% compound annual growth rate did not beat SPY buy and hold which was 6.58% over the same time period. However, the buy and hold drawdown was significantly worse at -56.47% against the 10/100 system maximum drawdown of -35.81%. Since the system does make many more trades than buy and hold, once commissions and slippage are factored in, results would be worse. Note too that trading the open is hard to replicate using all but the most expensive data packages because of how the opening price is reported by the exchanges. I would feel safer replicating trading at the close.
Let’s look at the historical profits and losses:
As the stats show, and as the author indicated, this is a trend following system. This means we can expect the system to take many small losses and gather fewer large wins. Over time, the large wins make up for the many small losses. This should be intuitive. Markets do not trend all the time. Small losses are taken until the market embarks upon a strong trend.
Reading about a trend following system can be awe-inspiring as 20 years worth of profits can be encapsulated in one graph. From experience, trading such a system is entirely different. It can seem like a lifetime when the system is whip-sawed over a year or so before it catches another winning trend. Perhaps this is another reason why these simple system can endure over time. Most people can not trade them consistently and long enough to significantly erode the edge.
I included this graph because it shows the typical trend following system profit distribution: Many small losses with fewer large wins.
The Bottom Line:
Overall, the 10/100 system is viable in that one is not likely to lose his starting equity if his life saving were to be thrown into it. If the goal is to beat buy and hold and decrease the associated drawdowns, the system is not viable. It does occur to me though that trading the SPY 10/100 system may be a good way to start trend following or system trading in that it is like learning how to ride a bike with training wheels…You can’t go very fast but you have some protection against crashes.
One final note. I backtested the system to 1928 using the non-tradeable S&P 500 index, and the results were remarkably similar to those above. This tells me that this system is not likely to break down or get much better. It will over and under-perform depending on the differing market regimes, but over time the performance should remain remarkably average with the benefit of decreased drawdowns.
Hopefully you learned from my previous post that a relentless bull market can cause bloggers who are tired of making money or are not making money (for whatever reason) to begin calling tops. Actually, I didn’t write that in that post, but I think there may be some truth to it. Luckily, I am not in either of those camps.
But what else do I write about during a raging bull market except a possible top?
So here we go. When we start to examine markets to try and gauge when exhaustion might begin, one of the ways I like the most is to count the number of days above a major moving average and then use that as a buy setup. It is very simple, easily re-created, and there are usually plenty of samples with which to work.
With that in mind…
- Buy $SPY or $SPX at the close when it has closed 77 days above its 200 day moving average.
- Sell X days later at the close.
- All $SPY history (~20 years) and all $SPX history (~80 years) used.
- No commissions or slippage included.
The results surprised me. Even though I have become inured to backtests that almost always show an upward bias, I was really expecting these results to show some increasing volatility, at the very least.
And I can’t even use sample size as a limiting factor for this study. The results are bullish and I feel comfortable saying so.
- SPY Samples: 898 occurrences with 41 held for the full 50 days
- $SPX Samples: 4011 occurrences with 187 held for the full 50 days
- $SPX Percentage of Winning Trades: 62.36%
- $SPX Average Winning Trade: 6.13%
- $SPX Average Losing Trade: -6.50%
At this point in the market history, with $SPX 77 days above its 200 day moving average, the market was higher 50 days later every 2 out of 3 trades. And on the downside, the losing trades were not very large relative to the winning trades.
Finally, lets take a look at the equity curve generated using $SPX:
The system occasionally catches huge winning trades: 1950-1960, 1980-1990, and 1990-2000.
Let’s look at the drawdowns:
The setup has been in a fairly significant drawdown since 2010. There has only been one other instance during the 1940s where the drawdown got worse. Should we expect that the current trade may be the one that begins erasing the drawdown rather than increasing it? If that is the case, this bull has much farther to run.
Your first sign that the title was a load of crap written solely for maximum clickatude is that I used an exclamation point. Only snake oil salesman and Timothy Sykes (but I repeat myself) use exclamation points in their titles. Your second sign that the title is simply bullshit is my post from last night where I wrote about how bull markets are bad for blogging. If those first two clues weren’t enough and you still haven’t figured out how unserious the title is, note the reference to Timothy Sykes in the body of this post, which can only have one purpose: to drive maximum traffic through agitation of the yahoo finance message board rejects.
Now that I have your attention…
I do have something more serious to discuss tonight, and that is the fact that the S&P 500 has traded above its 50 day simple moving average for 46 days.
Using this statistic as a setup, I’ve come up with a simple little study that should help us determine how much longer this market can trade before correcting.
- Buy $SPY or $SPX at the close when it has traded above its 50 day moving average for 46 days.
- Sell $SPY or $SPX at the close when it closes beneath its 50 day moving average.
- All $SPY and $SPX history used. $SPX history goes back to 1928.
- No commissions or slippage included.
Results Using $SPY:
The equity curve above was generated from trading the setup as a system with starting equity of $10,000.
- Number of Trades: 26
- % of Winning Trades: 19.23%
- Average % Gain / Loss: -0.44%
- Average Number of Days Held: 29
- Number of Days in Largest Win: 159
- Number of Days in Largest Loss: 13
The stats are telling us that if you are waiting for a close beneath the 50 day moving average to sell, there is a substantial chance that the market will be lower than today’s close when that happens. On average, it has taken the market about 5 weeks from this point before it closed beneath the 50 day average, but sometimes it trades higher for much longer (159 more days) and sometimes it starts to correct almost immediately (13 days).
Let’s Look at Results Using $SPX:
- Number of Trades: 107
- % of Winning Trades: 30.84%
- Average % Gain / Loss: 0.25%
- Average % Winning Trade: 5.32%
- Average % Losing Trade: -2.01%
- Average Number of Days Held: 30
- Number of Days in Largest Win: 213
- Number of Days in Largest Loss: 7
Looking back over 80 years, this setup seems to catch one good trade every decade or so. The rest consistently lose. What I find remarkable is that the average number of days the trade is held is stable over the long term and shorter term at roughly 30 days. If this pattern holds true, we can expect some weakness to begin in late March or early April.
But what if we wanted to be sure to catch the big winning once-in-a-decade trade while not losing too much on the rest? The answer is simple, really. We want to make sure we hold our winners longer while still cutting lose the losing trades before they kill the account. Here is what that looks like.
The only thing different is that now we are selling on a close beneath the 100 day moving average, rather than the 50. This change means our average trade is held for 84 days after the setup (versus 30). Look at how this simple change affects the average winning and losing trades:
- Average % Winning Trade 11.81% (vs. 5.32% for selling beneath 50 day average)
- Average losing trade -3.53 (vs. -2.01% for selling beneath the 50 day average)
This illustrates what happens when we hold winners longer while still selling losers for a reasonable loss. In real-life, most people find it incredibly difficult to hold winners long enough. This may be because their emotions override their knowledge, or because they don’t have enough knowledge to be able to override their emotions.
And that my friends is how you blog during a bull market.
Well it appears that last night’s post jinxed the market today. Either that or Fly’s tweet of my post caused a disturbance in the market equilibrium. Whatever the reason, today’s little blip caused quite a bit of teeth gnashing, except for those who were magically short going into the day.
Today marked the 34th day that $SPY closed above its 20 day simple moving average (MA20). Even after losing 1.3% on the day, the ETF managed to close just above the MA20. I suspect we’ll see some follow through tomorrow, which means $SPY will likely close beneath its MA20. With that in mind, let’s look at what has happened when this setup occurred in the past.
- Buy $SPY or $SPX at the Close when it Trades above its MA20 for more than 30 Days and then Closes beneath its MA20.
- Sell X Days Later.
- No commissions or slippage included.
- All $SPY history used. $SPX history starts in 1928.
$SPY results are the average of 21 trades held for the full 50 days. $SPX results are the average of 103 trades with 93 held for the full 50 days. Buy-n-Hold results are generated by chopping all $SPY history into 50 day segments and then averaging the segments.
If we were to only consider the past ~20 years of $SPY results, sample size would be a limitation in this study. The addition of almost 90 years of $SPX results lends more reliability to the results.
Its hard to ignore the edge here. If $SPY closes beneath its MA20 tomorrow, the future will look bright for the next 10 to 15 trading days. After that, history guides us to expect some consolidation or another small pullback.
For the traders who woke up today and magically found themselves short, neat trick. For the bulls, if the edge prevails, all of today’s losses will likely be erased. At that point it would be wise to consider whether to continue pressing your luck without reducing exposure or adding hedges.
A friend recently sent me this publication from Empiritrage: Volatility-Based Allocation. I encourage reading the document as the strategy is interesting, and a basic understanding of what they are testing will be necessary to understanding my article.
The general idea behind the strategy is to use two $VIX moving averages (10 and 30 day) and a 12 month moving average (250 day) to create Risk-on, Risk-off regimes for 5 asset classes:
- SP500 Index ($SPY)
- FTSE NAREIT All Equity REITS Total Return Index—benchmark for REITs ($IYR)
- MSCI EAFE Index—benchmark for investment in equity markets outside of U.S. and Canada ($EFA)
- MSCI EEM Index—benchmark for investment in emerging markets ($EEM)
- Merrill Lynch 7-10 year government bond index ($IEF)
A quick glance at slide 3 of the publication will provide a graphic presentation of how VBA works.
The backtested results presented in the publication were decent enough for me to consider adding VBA to my own portfolio. But before doing so, I wanted to see what would happen if tradeable securities were used instead of the total return indices (which are not able to be bought and sold).
I’m not sure what to make of the dividend distributions that are part the total return indices but not the price indices. My data is all price indices, meaning it is dividend adjusted. In real life, would trading in and out of $SPY or other tradeable asset classes mean missing some dividend distributions? I think it would, and I’m not sure how Empiritrage took that into account. I have sent them an email with a link to this post in case I have erred or in case they want to provide some clarity.
We can assume, since I will be using price indices (ETFs, actually) for testing the system, that my results will not be as good as their results since dividends will not be included. Other considerations are that ETFs do not perfectly track their underlying indices and can be subject to bid/ask and liquidity issues. I am also including a return on cash via $SHY (iShares 1-3 Treasury Bond ETF), but I have not calculated the return the same as Empiritrage as they used T-Bills. My goal is to test how VBA would work in real-life for a real person who chooses to manage his or her long term accounts. I will test the strategy over the data and securities that such a person is likely to have available.
I will present my results much the same way Empiritrage did, for the sake of easy comparison. All results are frictionless, meaning commissions and slippage have not been included. Trades are made and portfolios are rebalanced once a month, on the first trading day of the month.
It has been a rough decade for these asset classes. While $EEM returned 15.30%, its maximum system % drawdown was a killer. The Core 5 EW, which is simply all five classes held in equal weights, also had a killer maximum drawdown. What Empiritrage is seeking to accomplish is to replicate the returns without the risk.
Let’s see if their volatility-based allocation strategy is able to do that.
The volatility-based allocation (VBA $SPY) was able to come close to the $SPY benchmark return while significantly lowering risk metrics.
- Exposure was reduced by roughly 60%
- Maximum System % Drawdown was reduced by 80%
- Sharpe Ratio more than doubled compared to the other strategies.
If the goal is to beat the S&P 500 and include some downside protection, the ROC(5,252) and MA(2,12) have accomplished it. But with increased CAGR comes increased risk. I do not think it is possible to separate the good from the bad, but the VBA strategy shows on $SPY that it is possible to keep most of the good and throw out most of the bad.
The Volatility-Based Allocation Equity Curve
Click on the charts to make them bigger…
Upon seeing the equity curve, I started thinking that it would be hard to stick with this system from 2003 – 2006 when the market was steadily trending up and the system was losing money. And therein lies the system trader’s dilemma.
The next post will take a look at how this strategy has worked with the other 4 asset classes, and will then run the strategy over all 5 classes equally weighted. If there are any questions, please let me know in the comments. I have glossed over quite a few of the specifics in order to make this post manageable.
Exit question: Is the market making a huge triple top?