Backtest stocks based on strongest Relative Strength over a period
Author: Robls
Creation Date: 11/6/2014 11:05 AM
profile picture


I have searched the forums, and apologize if I missed a question and/or answer to this.
What I would like to do is back test the S&P 500 components based on the stocks showing the strongest Relative Strength over a given number of periods, 20 days, 1 year, etc...
I would like to select only the top 20 percent say (100 stocks) showing the strongest Relative Strength using different back test parameters.
Is there a way to do this in WL?
Thanks for any and all help on this.
profile picture


Hi Rob,

This is called Rotation Strategy. Several of them are built in Wealth-Lab, to be found under "Open Strategy" > "Symbol Rotation" folder, and more can be downloaded ("Download..." button). The one you're looking for is called "RSI Rotation".

Note that rotational strategies must be executed in single-symbol backtest mode (i.e. on a single symbol, not as portfolio backtest). They perform entries in multiple symbols internally, though. More advice in the FAQ | Strategies and WealthScript > Rotation strategies.
profile picture


Make sure to see the Strategy's summary for more tips regarding position size. Also, I'd guess that holding 25 or even fewer names would provide better results.
profile picture


I have looked at the code and noticed that Relative Strength is noted as RSI. I thought that the Wilder's Relative Strength Index is quite different from the simple Relative Strength of (stock price/S&P500). I am looking for info on the latter. Specifically, how would I calculate it and then how would I plot it?

Jim K.
profile picture


Good point Jim. Topic starter's question is ambiguous. "RS" could actually mean "RSI". Anyway, the Wiki FAQ has to say something about it:

FAQ | Strategies and WealthScript > Rotation strategies > "I need other rotation rule other than the built-in RSI."

There are lots of examples on how to calculate and plot the Relative Strength (see links below). These topics are more suitable than this one if you're not looking to integrate RS into a rotation system (which we're focusing on here):

RS Mansfield
Is there a canned indicator that shows price performance comparison as relative strength?
how to code relative strength using GetExternalSeries?
Relative Strength rotation system