Momentum Traders

We all hear that many institutions look at the momentum strategy where you go long when the 50 day moving average is above the 200 day average. As you will see below from 1993 this has been a pretty effective strategy using daily data applied to the S&P 500. For your information the strategy is still long despite the recent volatility.

Here is a chart showing the moving averages, the yellow is the 50 day and the red is the 200 day.

Rplot07

 

Here are the backtest results:

2015-01-23_1313 Rplot043

For those wanting to see the R code generating these charts and stats here it is:

require(quantmod)
require(PerformanceAnalytics)
 
#get the data and fill out the MA
getSymbols('SPY', from='1950-01-01')
SPY$ma200 <- SMA(Cl(SPY), 200)
SPY$ma50 <- SMA(Cl(SPY), 50)
 
#lets look at it from 1990 to 2015
spy <- SPY['1990/2015']
 
#our baseline, unfiltered results
ret <- ROC(Cl(spy)) 
 
#our comparision, filtered result
ma_sig <- Lag(ifelse(SPY$ma50 > SPY$ma200, 1, 0))
ma_ret <- ROC(Cl(spy)) * ma_sig
 
golden<- cbind(ma_ret,ret)
colnames(golden) = c('GoldCross','Buy&Hold')
 
#Plot to visually see the actual moving averages
chartSeries(spy, 
            type = "line",
            name = "Moving Average : Golden Cross",
            TA= c(addSMA(50, col = 'yellow'), addSMA(200)))
 
# lets see what the latest signals are 1 being a buy signal
tail(ma_sig)
 
maxDrawdown(golden)
table.AnnualizedReturns(golden, Rf= 0.02/252)
charts.PerformanceSummary(golden, Rf = 0.02, main="Golden Cross",geometric=FALSE)

Created by Pretty R at inside-R.org

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s