Mean Reversion based on RSI
One of the categories of trading systems is mean reversion. While trend following systems enter long positions after a period of strength in anticipation of further strength, mean reversion systems enter long positions after a period of weakness in anticipation of return to average.
Compare a trend following system using the same data.
It is common for mean reversion system to be based on an indicator that measures the extent that prices are above or below the average. One such indicator is the RSI (Relative Strength Index). Larry Connors and Cesar Alvarez published several short term trading systems in their book “High Probability ETF Trading.” One is a mean reversion system based on buying when the RSI is low and shorting when the RSI is high. Details can be found in Chapter 3, “RSI 25 and RSI 75.” The system has two versions – basic and aggressive.
Daily data for SPY for a period of about twelve years are used. The beginning and ending dates are chosen intentionally so that the period has very little net price change. SPY closed at 126.31 on 1/28/1999, and closed at 126.66 on 10/31/2011.
While there was little net price change over that period, there were five large moves within it.
Rise from 126 to 155 in March, 2000.
Drop from 155 to 77 in October 2002.
Rise from 77 to 156 in October 2007.
Drop from 156 to 67 in March 2009.
Rise from 67 to 126 in October 2011.
This is the same data used for the analysis of the 200 day moving average system.
For all runs, the initial equity was set to $100,000.
The AmiBroker code that follows implements the basic version.
// ConnorsRSIBasic.afl // // Based on "High Probability ETF Trading" // Larry Connors and Cesar Alvarez // Pages 23 through 36 // // This is a mean reversion system. // // The base indicator is a 4 period RSI. // Buy when RSI(4) is low, Short when it is high. // // Programmed by Howard Bandy // November 2011 // // Long rules (basic version): // Buy: C above 200 day moving average // RSI(4) of Close < 25 // Sell: RSI(4) > 55 // // Short rules (basic version): // Short: C below 200 day moving average // RSI(4) of Close > 75 // Cover: RSI(4) < 45 // // Connors tested through 12/31/2008 // 1/1/2009 through 11/14/2011 is out-of-sample // // Connors tested on a group of 20 liquid ETFs // These results are for those same ETFs // SetOption( "InitialEquity", 100000 ); MaxPos = 20; SetOption( "MaxOpenPositions", MaxPos ); SetPositionSize( 10000, spsValue ); RSILength = 4; MALength = 200; RSIBuyLevel = 25; // Basic version RSISellLevel = 55; RSIShortLevel = 75; // Basic version RSICoverLevel = 45; CloseAboveLongTermMA = C > MA( C, MALength ); RSI4 = RSIa( C, RSILength ); Buy = RSI4 < RSIBuyLevel AND CloseAboveLongTermMA; Sell = RSI4 > RSISellLevel; Short = RSI4 > RSIShortLevel AND !CloseAboveLongTermMA; Cover = RSI4 < RSICoverLevel; e = Equity(); Plot(C,"C",colorBlack,styleCandle); Plot(e,"equity",colorGreen,styleLine|styleOwnScale); //////////////////// end ////////////////////////
The first run was made using the basic rules and assuming that all available funds were used to take each position.
A chart follows that shows the price series of SPY as black candlesticks, and a green line showing the account balance. The vertical purple line is set at 1/1/2009. The Connor's book was published early 2009. The system was developed using data through 12/31/2008. Since it is highly likely that the system was adjusted so that the published results would look good, the period before 1/1/2009 should be considered to be in-sample. The data following 1/1/2009 was not used to develop the system and is out-of-sample.
The chart showing equity growth and drawdown follows.
The report giving the statistics follows.
Note that 80 percent of trades were profitable, with a maximum drawdown of 13% which occurred in 2011.
The aggressive version waits for prices to be further from the mean before taking a position. The RSIBuyLevel changes from 25 to 20, and the RSIShortLevel changes from 75 to 80. Exits remain the same at RSI levels of 55 and 45.
The chart showing account growth follows.
The report giving the statistics follows.
Note that the percentage of trades that are winners remains above 80%, and maximum drawdown remains at about 13%.
Trading a $10,000 basic unit
In order to evaluate the profit potential, risk, and position size, the system was re-run. Each trade is $10,000 – a "basic unit." All trades signaled from both the basic and the aggressive versions were taken.
The chart and report giving the statistics for the entire 12 year period follows.
The charts and reports shown so far are typical of those produced during the design, testing, and validation of trading systems. The next section expands the analysis into profit potential, risk and drawdown, and position sizing taking the trader's personal risk tolerance into account.