Wednesday, May 12, 2010

Developing A Trading Strategy (Part 3)

This is the final installment of our series on developing a trading strategy.

In part 1, I looked at a common trend following strategy of buying the S&P500 when prices are above the 40 week moving average and selling the S&P500 when prices are below. This is a simple, easy to manage strategy, but often times (in trading), simpler is better. As it turns out over the test period, the strategy did not beat buy and hold S&P500 and it did not improve upon the equity curve draw down. In the end, one has to seriously question what benefit to their portfolio this simple trend following strategy offers.

Certainly ease of execution has to be considered, and with this in mind, maybe there is some filter that can improve the strategy's return and draw down. In other words, maybe there is a filter that will get rid of the bad trades and preserve the good ones.

In part 2, we looked at one filter and this was our indicator constructed from the trends in gold, crude oil, and yields on the 10 year Treasury bond. See figure 1, lower panel. When these trends are collectively strong, equities underperform. When these trends are not extreme, equities outperformed significantly. As we showed in part 2, a strategy employing this indicator alone out performed buy and hold S&P500 by 1.6 times, but it still left us with an equity curve draw down of 46%. This certainly is too high, but as we will show in this article, the combination of a trend following strategy (from part 1) with the filter (from part 2) will improve our draw down without sacrificing the gains.

Figure 1. Composite Indicator/ weekly

I concluded part 2 with the following comments:

While far from perfect, our filter appears to have the potential to improve our simple moving average system. Furthermore, a moving average, being price sensitive, will always keep us on the right side of the trend. Therefore, this will likely improve the function of the filter and help us avoid the bear markets. In part 3 of this series, it is my expectation that synergies of the moving average system and filter will be realized when combined together.

So this brings us to part 3 or this article, and here we will combine the trend following strategy of part 1 with the filter we used in part 2 into a single easy to follow strategy.

The data set is weekly data of the S&P500 with the first trade initiated in 1985.

The buy signal requires the 1) S&P500 to above the 40 week moving average; and 2) the indicator in figure 1 to be below the extreme line (i.e., weak trends in gold, yields on the 10 year Treasury, and crude oil).

The sell signal occurs if 1 of 2 things happen: 1) the indicator in figure 1 moves above the extreme line; or 2) price of the S&P500 has closed below the 40 week moving average for 2 consecutive weeks.

All trade signals are executed at the weekly close; slippage and commissions are not considered. There were no stop losses utilized.

So how does our new combination strategy perform?

Since 1985, there were 57 trades producing 1666 S&P500 points. Buy and hold produced 978 S&P500 points. 58% of the trades were profitable; this is a nearly 50% improvement over the trend following strategy in part 1 where only 40% were profitable. Equity curve draw down has been reduced to 15%, which is extraordinary over buy and hold.

The equity curve for this strategy is shown in figure 2.

Figure 2. Equity Curve

The maximum adverse excursion graph is shown in figure 3, and this will give us an idea of how each trade performed. We note that the majority of winning trades (green carets) had an MAE of less than 4%; this is to the left of the blue line. There was one trade that had an excessive drawdown and this was in 1998. As it turns out, this was the only trade with a loss greater than 5% - pretty amazing.

Figure 3. MAE Graph

Ok, what have we done? In part 1, we looked at simple trend following strategy, and what we found is that it underperformed buy and hold S&P500 and it did not improve any of our risk metrics. In part 2, we looked at a filter to improve the quality of our signals, but because there was no price sensitive filter (i.e., a moving average) to keep us on the right side of the trend, draw downs remained high. In part 3, we combined both tools (trend following plus filter) and we get a strategy that easily beats buy and hold and has extraordinary risk characteristics. In essence, we have developed an easy to follow trading strategy.

Lastly, let me mention that as of this past Friday this strategy is on a buy signal. Prior to that the strategy was out of the market and on a sell signal from March 12, 2010.


Sharpe Trader said...

Nice article.

Can you please tell me what software you were using for the backtesting?

Thank you,
Sharpe Trader

Guy M. Lerner said...



Nice picture too!

Anonymous said...

This is a really promising model, with a beautiful equity curve. You have done your homework with the MAE analysis.

I have one suggestion concerning the tripartite indicator, composed of gold, crude oil and 10-year T-notes. In more inflationary times, rising T-note yields were a reliable indication of inflationary pressure on stock prices ... and vice versa, when yields fell.

However, during the Lehman crisis in 2008, a safe-harbor flight to Treasury debt held yields down, even though conditions were quite negative for stocks. During this period of credit stress, rising yields on lower-rated corporate debt did a better job of signaling an unfavorable environment for stocks.

Thus, my suggestion: in place of the 10-year T-note yield, why not substitute the yield on Baa-rated corporate debt? The Federal Reserve's website provides a weekly data series beginning in 1962:

My guess is that in a future filled with credit worries and flights to quality, the yield on lower-rated debt (which has more in common with equities) will more accurately reflect whether the environment is favorable for stocks.

Again, congratulations on this insightful, robust model. And on extracting a profit from your short signal, after weeks of waiting!

Guy M. Lerner said...


1) Thank you

2) I am glad to see someone is paying attention!

3) At one point in time I substituted the crb index for crude and looked at the 3 together going back to 1973 and the results were similar

4) I will look at the yield on BAA corporate debt to see if that makes a difference

Anonymous said...

Guy --

I pay attention, having developed some trading systems myself.

Interest rates are an extremely important input -- I used 5-year T-note yields. But they degraded performance during 2008 by falling on the safe-haven trade. The model interpreted this as 'plentiful liquidity' when in fact, it was the opposite -- a near seizure of all credit markets EXCEPT for Treasurys.

By the way, using weekly data, I encountered the same MAE problem you did in Sep-Oct 1998. The weekly data was just not granular enough to get out of the way in time.

Thanks again for your great work.

-- Michael B.

Guy M. Lerner said...

Michael B:

The time frame issue cuts both; sometimes using weekly charts keeps you out of the noise and sometimes it is too slow to respond. One solution is to convert the weekly signals to a daily time frame and then trade basic technical set ups using the weekly signals as a back drop. Or you can use both weekly and daily trading signals - just don't rely upon one