A reader asked if I could backtest a trading strategy based on the RSI(2) technical indicator. Most RSI strategies trade mean reversion setups, however, this is actually a trend following strategy.
The idea is to follow trends and use an RSI(2) pullback to get a better price entry. We wait for the RSI(2) to turn back up before entering the trade then place a stop loss at the previous swing low.
The full buy and sell rules of this strategy can be described as below:
- Close > MA(200)
- MA(5) > MA(200)
- RSI(2) crosses over 10
- 21-day average turnover > $200000
- Close > 2
- MA(5) < MA(200)
- Stop loss placed at swing low before RSI cross (lowest 5-day low)
The following chart provides a trade example in United Airlines (UAL):
If you look closely you can see that RSI(2) drops below 10 on the 26th April 2018. It then crosses back above 10 on the next bar.
Meanwhile, the close is above the 200-day MA (blue) and the 5-day MA (orange) is also above the 200-day MA. The stock also meets our liquidity rules with an average turnover > $200,000 and a stock price > $2.
A buy order is therefore sent for the next open (green arrow) and a stop loss is placed at the recent swing low of $65.45 (red line).
The stock comes close to taking out the stop loss on May 10th but fortunately the stop is never hit.
218 days later, we get our exit signal as the MA(5) crosses under the MA(200). The trade is closed on the following open (red arrow) for a total profit of 21.81% after costs.
This trade example shows how the system is able to hold on to some relatively choppy upward trends in stocks.
To backtest this strategy I will be using the software Amibroker with historical data from Norgate. This data includes delisted stocks and is adjusted for capital actions and dividends.
I will first run an All Trades test which will test every trade signal over the time period. I will then run a portfolio test to account for more realistic trading conditions.
A portfolio test represents how a trading strategy could be implemented in real life as it accounts for trading constraints such as position sizing, portfolio size and transaction costs.
Backtest Results – All Trades
To run the all trades test we will use the following backtest conditions:
- Universe: S&P 100, S&P 500, Russell 3000
- Date: 01/01/2000 – 01/01/2019
- Execution: Next day open
- Position size: $500
- Transaction Cost: 0
The following table shows backtest results for all signals across S&P 100, S&P 500 and Russell 3000 stocks between 1/2000 to 1/2019:
As you can see from these results, the strategy has been profitable over the last 19 years. We recorded an average profit per trade of 1.83% in the S&P 100, 2.15% in the S&P 500 and 1.91% in the Russell 3000.
The risk-adjusted return of 9.34% in the S&P 500 is more than the buy and hold return which was 4.85% on SPY.
However, these are less than stellar returns. The win rate is particularly poor at only 15-16%. The Sharpe ratio is also poor.
Backtest Results – Portfolio
Before we move on, we can see how this strategy stacks up with full portfolio implementation. We will use the following backtest settings for the portfolio simulation:
- Universe: S&P 500
- Date: 01/01/2000 – 01/01/2019
- Transaction Cost: $0.01 per share
- Execution: Next day open
- Starting Capital: $25,000
- Max open positions: 20
- Position size: 5% (equal weight)
- Ranking: RSI(2) highest first
The following results and equity curve show the performance of the strategy as a portfolio between 2000 and 2019 on S&P 500 stocks:
- # Trades: 1806
- Net Profit: $83358.42
- CAR: 8.02%
- MDD: -47.5%
- CAR/MDD: 0.17
- RAR: 8.31%
- Win Rate: 19.49%
- Avg P/L Per Trade: 2.58%
- Average bars held: 51.38
- Payoff Ratio: 8.21
- Sharpe: 0.11
As you can see from the above results, this trading strategy has been profitable on S&P 500 stocks with an annualised return of 8.02% and a RAR of 8.31% which beats the SPY buy and hold return of 4.85% over the same time period.
The results are not impressive but there are some good features present in these results.
For example, the system made 44.5% in 2013 and 38.7% in 2017. Those are strong results. The strategy appears to do a good job of capturing returns in up years.
However, there are still big concerns over the low win rate and large drawdowns.
Simple Adjustments To Improve Profits
A couple of things stand out when analysing these results.
First, the win rate is very low (less than 20%). This leads to a maximum losing streak of 63 consecutive trades in the backtest. Most traders would not be able to trade through such a poor losing period.
Second, the CAR/MDD is not good. The max drawdown is almost six times larger than the annualised return.
However, there are numerous adjustments that could be made to improve performance.
- We could introduce a regime filter to keep the system flat during down markets.
- We could alter the sell rules to improve win rate and shorten trade duration.
- We could use sector and portfolio rules to limit trades to certain sectors or industries.
- We could utilize more dynamic position sizing and investigate different ranking.
Of course, there is no limit to the number of ideas that could be added or taken away from this system.
As an example, I have made three simple adjustments to this strategy as below:
- Instead of exiting by the stop loss intraday we will delay the exit to the next market open. This will give the trade a little more time to recover and simultaneously reduce slippage costs.
- We will use an SPX filter so that we can only enter trades when the S&P 500 is over the MA(200). This will help to keep us out of volatile markets.
- Instead of ranking by RSI(2) we will rank by ATRP and choose the lowest volatility stocks first. The idea is that we can find trends that are less likely to hit their initial stop loss.
Backtest Results After Improvements
The following results and equity curve show the performance after making these three adjustments:
- # Trades: 1458
- Net Profit: $87266.46
- CAR: 8.22%
- MDD: -18.31%
- CAR/MDD: 0.45
- RAR: 10.67%
- Win Rate: 27.30%
- Avg P/L Per Trade: 2.77%
- Average bars held: 50.36
- Payoff Ratio: 7.44
- Sharpe: 0.15
You can see that the maximum drawdown has dropped from -47.5% to -18.31% and the win rate has increased to 27.30%. Meanwhile annual return has improved to 8.22% and RAR has improved to 10.67%:
The trading system is now a lot more stable although we did begin with three consecutive losing years and the annual return is still not impressive.
In this article we have backtested a readers RSI strategy and produced some meaningful results.
The low win rate and poor annual return are not up to scratch for most traders and this can result in long losing streaks.
However, the system does a reasonably good job of picking out winning trends in up markets. Not many systems were able to generate thirty to forty per cent returns in 2017.
This strategy may therefore have some potential if it can be limited to bull markets only. It may also be interesting to test on intraday data.
A trader who is skilled at identifying market regimes may be able to use this strategy (or something similar) as a base to help capture trends. But in its present form it could do with some work.
Simulations produced in Amibroker using historical data from Norgate.
Thank You For Reading
Joe Marwood is an independent trader and the founder of Decoding Markets. He worked as a professional futures trader and has a passion for investing and building mechanical trading strategies. If you are interested in more quantitative trading strategies, investing ideas and tutorials make sure to check out our program Marwood Research.
This post expresses the opinions of the writer and is for information, entertainment purposes only. Joe Marwood is not a registered financial advisor or certified analyst. The reader agrees to assume all risk resulting from the application of any of the information provided. Past performance is not a reliable indicator of future returns and financial trading is full of risk. Margin trading can lead to losses more than in your account. Mistakes in backtesting and presenting of analysis regularly occur. Please read the Full disclaimer.