A Moving Average Backtest on the S&P 500 to 1987

Regular readers of the blog know I focus my investment curiosity on a few key areas, primarily momentum, long term portfolio systems for individual investors, moving averages, dividends/value, and educational materials that discuss these areas.

My favorite book of late to discuss most of these ideas is Mebane Faber’s The Ivy Portfolio: How to Invest Like the Top Endowments and Avoid Bear Markets. Another book, which, in full disclosure I have not yet read so I cannot give it an official endorsement (but I am a frequent visitor to the author’s website), that discusses momentum and moving average systems is Tom Lydon’s The ETF Trend Following Playbook: Profiting from Trends in Bull or Bear Markets with Exchange Traded Funds.

I performed a 10 month simple moving average crossover system test on VFINX, Vanguard’s S&P 500 mutual fund which has historical data available back to March 1987 on Yahoo Finance. I chose VFINX because it has a historical record and is an easily accessible trading vehicle for most individual investors.

The system was inspired by Faber’s book and is not intended for frequent traders. It purchases the underlying security when its monthly close is above the 10 month simple moving average. The security is sold when its monthly close is below the 10 month simple moving average.

The system was tested using Ninja Trader (an excellent free software platform). The historical data is dividend/split adjusted based on Yahoo Finance data. Note for Ninja Trader users: I had to manually import Yahoo dividend adjusted monthly data into NT in order to perform the backtest. I’ll look to post instructions on how to do this in a future post.

Below are the results of the backtest, with charts. I used purchases of 1 share since my goal was to compare percentage returns. The system required VFINX be trading for at least 10 months in order to get a calculation for the 10 month SMA; thus, the first available purchase was technically not until February 1988.

The CAGR was 10.76% if we assume a full 22 years of data. The cumulated profit was 724.46% and the max drawdown was -5.16%. Conversely, buy and hold from July 1988 (the date of the first trade in the 10 month system) to Friday had a cumulative profit of 517.36% and CAGR of 8.63%.

What do the results tell us? Nothing by itself. 22 years is actually a fairly short timeframe to backtest a system that has such infrequent trades. In addition, we need to test it on other markets (upcoming in future posts). However, when compared to the results in Faber’s book, the underlying result is generally the same–positive when compared to buy and hold. As an aside-Faber used indices in his book and thus had access to a much longer data set.

The goal of this test was to backtest a system using an actual trading vehicle–a mutual fund–which has an expense ratio (unlike an index) and does not have a bid/ask spread like a stock. Thus, we can eliminate some unknowns such as commission (assuming you are buying/selling the Vanguard fund directly with Vanguard or with a broker who does not charge a commission for Vanguard funds) and slippage. Taxes are obviously a huge variable, however the system traded infrequently – 13 roundtrips in approximately 22 years; in addition, one could trade it in an tax-deferred account.

Performance All Trades
VFINX Trend Analysis
Total Net Profit 135.52
Gross Profit 143.04
Gross Loss -7.52
Commission 0
Profit Factor 19.02
Cumulated Profit 724.46%
Max. Drawdown -5.16%
Start Date 01/01/87
End Date 10/09/09
Total # of Trades 13
Percent Profitable 69.23%
# of Winning Trades 9
# of Losing Trades 4
Average Trade 21.26%
Average Winning Trade 32.63%
Average Losing Trade -4.32%
Ratio avg. Win / avg. Loss 7.56
Max. conseq. Winners 3
Max. conseq. Losers 2
Largest Winning Trade 133.33%
Largest Losing Trade -10.20%
# of Trades per Day 0
Avg. Time in Market 443.08 days
Avg. Bars in Trade 14.5
Profit per Month 0.83%
Max. Time to Recover 790.00 days

e) {}" href="http://1.bp.blogspot.com/_P3-bTZucYzA/StDzoqekbJI/AAAAAAAAAKI/V9ZKiNYqEgo/s1600-h/NinjaTrader+Cumulated+Profit+Report,+1_1_1987+-+10_9_2009.jpg">

e) {}" href="http://2.bp.blogspot.com/_P3-bTZucYzA/StD0i4vAR6I/AAAAAAAAAKY/mAPc6nSGZX8/s1600-h/VFINX++6_4_1987+-+10_3_2000+%2810+Day%29.jpg">

e) {}" href="http://3.bp.blogspot.com/_P3-bTZucYzA/StD0LeTX_MI/AAAAAAAAAKQ/knMh9bQiLCw/s1600-h/VFINX++10_9_1999+-+10_6_2009+%2810+Day%29.jpg">

4 thoughts on “A Moving Average Backtest on the S&P 500 to 1987”

  1. I did a similar test using the ETF SPY. I used an order lot size of 100 and commission of $10.95 per trade. I did two backtests. The first was using a 20 Month Simple Moving Average (See Results Below). And, the second was with Bollinger Bands with a 20 Month Moving Average. With the Bollinger Bands, I purchased when the close crossed above the Middle Band and went flat when the close crossed below the Middle Band. Again, I used an order lot size of 100 and commission of $10.95 per trade. (See Results Below).

    The test with the Bollinger Bands gave me slightly better results:

    [20 Month SMA Cumulated Profits: 626.62%]
    [20 Month Bollinger Bands Cumulated Profits: 819.65%]

    By the way, how did you calculated CAGR?

    Ernest H Harris

    Performance All Trades
    SPY [20 Month SMA]
    Total Net Profit 12786.80
    Gross Profit 12786.80
    Gross Loss 0.00
    Commission 43.80
    Profit Factor 99.00
    Cumulated Profit 626.62%
    Max. Drawdown 0.00%
    Sharpe Ratio 1

    Start Date 01/01/80
    End Date 10/10/09

    Total # of Trades 2
    Percent Profitable 100.00%
    # of Winning Trades 2
    # of Losing Trades 0

    Average Trade 216.28%
    Average Winning Trade 216.28%
    Average Losing Trade 0.00%
    Ratio avg. Win / avg. Loss 2.16

    Max. conseq. Winners 2
    Max. conseq. Losers 0
    Largest Winning Trade 381.72%
    Largest Losing Trade 0.00%

    # of Trades per Day 0
    Avg. Time in Market 1948.50 days
    Avg. Bars in Trade 64
    Profit per Month 1.27%
    Max. Time to Recover 2223.00 days

    Performance All Trades
    SPY [20 Month Bollinger Bands]
    Total Net Profit 14868.40
    Gross Profit 14868.40
    Gross Loss 0.00
    Commission 65.70
    Profit Factor 99.00
    Cumulated Profit 819.65%
    Max. Drawdown 0.00%
    Sharpe Ratio 0.01

    Start Date 01/01/80
    End Date 10/10/09

    Total # of Trades 3
    Percent Profitable 100.00%
    # of Winning Trades 3
    # of Losing Trades 0

    Average Trade 172.25%
    Average Winning Trade 172.25%
    Average Losing Trade 0.00%
    Ratio avg. Win / avg. Loss 1.72

    Max. conseq. Winners 3
    Max. conseq. Losers 0
    Largest Winning Trade 452.70%
    Largest Losing Trade 0.00%

    # of Trades per Day 0
    Avg. Time in Market 1309.00 days
    Avg. Bars in Trade 43
    Profit per Month 1.24%
    Max. Time to Recover 2253.00 days

Comments are closed.