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. 

Basic version

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.

Aggressive version

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.

Profit Potential and Risk

Using the techniques described in Modeling Trading System Performance, estimates of future performance can be made. The process begins with any one of several descriptions of the trades that are anticipated in the future. The best estimate usually comes from either trades actually made over a recent period of time or the out-of-sample trades from validation tests such as walk forward tests. If you have reason to believe that the future will differ from the period that produced the OOS trades, you may adjust the data used for the analysis to reflect that bias.

If we were confident that all of the results (1999 through 2011) were out-of-sample, we could use all 165 trades. If we believed that the future would be similar to a particular period in that range, we could use those results. The 50 trades from 1/1/2009 through 10/31/2011 are certain to be out-of-sample and are the best estimate we have for performance over the next few years. We will use those 50 trades without any adjustment.

The chart and report for those trades follow.

Note that 80% of all trades are winners and the maximum drawdown is about 3%, both of which are consistent with the results for the entire period, which is encouraging.

The amount won or lost on each trade ranges from a loss of 7.8% to a gain of 5.4%, as the following chart shows.

The estimations require a defined future time horizon. Make that period long enough so the simulation includes enough trades in the period to be smooth, but short enough so that you can imagine trading the system from now until it ends. I find four years is a good choice. The out-of-sample period covered 34.5 months and generated 50 trades. A four year period will have about 70 trades.

The Monte Carlo method used will draw 70 individual trades from the set of 50 trades in the OOS data using “sampling with replacement.” Each trade will be a fixed dollar amount, $10,000. The account balance at the end of the four year period (the terminal wealth relative or TWR to follow Ralph Vince’s terminology) and the maximum drawdown, MaxDD, (computed from highest equity to date) are computed and remembered. After this process is performed 1000 times, the distribution of TWR and MaxDD can be computed. The charts of each follow.

This chart shows that, providing the future is reflected in the data used, the mean terminal wealth is expected to be about 7.5% greater than the initial wealth. A gain of 7.5% over four years is a Compound Annual Rate (CAR) of 1.8%. TWR at the 5th percentile is 1.037, or a CAR of 0.9%. TWR at the 95th percentile is 1.111, or a CAR of 2.7%. The interpretation of these numbers means that CAR will be less than 0.9% only 5% of the time; and it will be less than 2.7% 95% of the time. That is, the CAR will be between 0.9% and 2.7% about 90% of the time, with an expected value of about 1.8%.

This chart shows that the maximum drawdown, as measured from highest equity to date, will be between 0.7% and 2.1% about 90% of the time, with an expected value of about 1.1%. An ideal distribution would be very flat, without a high tail on the right. The high tail represents a small probability of a higher drawdown. Note the right side of the chart and the tail of this distribution. Although with 95% confidence the drawdown will be limited to 2.1%, there is a small chance that the drawdown will be greater – up to about 4%. Expect the shape of the distribution of drawdown to be the same regardless of the position sizing method used. In order to reduce the probability of a high drawdown, reduce both the number and particularly the size of losing trades.

In summary, if every trade signaled by the RSI system is taken with a position size of $10,000, an account with an initial balance of $100,000 will grow by between 0.9 and 2.7 percent per year and will have a maximum drawdown over a four year period of between 0.7 and 2.1 percent.

Position Sizing

If the trader’s personal tolerance for risk is such that he or she will continue to trade a system up to a drawdown maximum of, say, 15%, then the position size can be increased.

Additional simulation runs were made. Rather than a fixed number of dollars per trade, a percentage of the account balance will be used – a method known as “fixed fraction.” The fraction was increased in steps from 5% to 200% and the distribution of both TWR and MaxDD examined. The trader must decide how great a risk to take and decide which percentage of fixed fraction to use. The trader must decide on two numbers – the maximum level of drawdown and the certainty that that level will not be exceeded. This analysis will use a 15% maximum drawdown at the 95th percentile. If the trader wants to be very conservative, she should use the drawdown percentage at the 98th, 99th, or even 100th percentile.

This chart shows that maximum drawdown at the 95th percentile reached 15% when the fraction of the account used for each trade was 0.75. That is, use 75% of the account for each trade. Since there can be two positions held, one for the basic signal and one for the aggressive signal, the maximum used would be 150%, which would require use of margin. Alternatively, leveraged exchange traded funds could be used without need for margin.

CAR was also recorded for each of the simulation runs. When a fraction of 0.75 is used, CAR at the 5th percentile is about 6.5%.

Reducing the fraction used for each trade will reduce the drawdown, but will not change the shape of the distribution. If there is a high tail when the fixed amount of $10,000 per trade is used, there will be an equally high tail for all fractional amounts. Reducing the fraction to reduce the drawdown also reduces the CAR. A useful metric compares the risk of maximum drawdown with the CAR – divide CAR at the level of it you want to use by the MaxDD at the level of it you want to use. A conservative choice would be CAR at the 5th percentile divided by MaxDD at the 95th percentile. You can expect both conditions to be satisfied about 90 percent of the time – CAR greater than the value at the 5th percentile and also MaxDD less than the value at the 95th percentile.

Examine the distributions

Having decided on a value of 0.75 for the fraction, the distribution of terminal wealth and maximum drawdown can be examined.

Terminal wealth is expected to be greater than 1.27, a CAR of 6.1%, with 95% probability; and is expected to be less than 2.28, a CAR of 22.9%, with 95% probability. That is, with 90% probability, the CAR will be between 6.1% and 22.9% for the next four years. The mean CAR is 15.0%.

Maximum drawdown is expected to be greater than 5.6% with 95% probability; and is expected to be less than 15.7% with 95% probability. That is, with 90% probability, MaxDD will be between 5.6% and 15.7% for the next four years. The mean MaxDD is 8.5%. Note that there is a high tail, and with small probability maximum drawdown could be as high as 38%.

The ratio of CAR05 to MaxDD is a useful metric by which to compare alternative trading systems. For this example, it is 6.1 to 15.7 or 0.39, which is reasonable. Ratios of 1.0 are excellent.

Straw Broom Chart

Measured by the mean TWR or CAR, the account balance after four years will show a gain of about 75%. But using a single number, such as the mean CAR, is often misleading. It is valuable to examine the distribution and consider some of the specific equity curves that could result from trading the system. The next chart shows ten equity curves, all equally likely. The dark black line is the average of the ten.

Note the spread of the final balance. The lowest of the ten shows an increase of only 17%, and after having spent three of the four years net negative. The best shows the account doubling.

Summary

The main points are:

  • Think about how great a drawdown you would be willing to trade through before abandoning a system. Use that to determine your personal risk tolerance.
  • Estimations of future profit potential and risk come from using the best estimates of trades.
  • Examine the distributions or profit and drawdown, rather than rely on a single number such as the mean, or even two numbers such as mean and standard deviation.
  • To establish the distributions, use a set of trades where each is a constant size.
  • Run a series of simulations to determine the maximum fraction that can be used while keeping maximum drawdown within your tolerance.
  • Examine the distributions of terminal wealth and drawdown using that fraction.
  • Examine several equity curves that are all equally likely.

A bejegyzés trackback címe:

https://vilagbagoly.blog.hu/api/trackback/id/tr44341505

Kommentek:

A hozzászólások a vonatkozó jogszabályok  értelmében felhasználói tartalomnak minősülnek, értük a szolgáltatás technikai  üzemeltetője semmilyen felelősséget nem vállal, azokat nem ellenőrzi. Kifogás esetén forduljon a blog szerkesztőjéhez. Részletek a  Felhasználási feltételekben és az adatvédelmi tájékoztatóban.

Nincsenek hozzászólások.
süti beállítások módosítása