Rotation Strategy: Current Price vs. Price n-Days Ago
Author: rmpwealth
Creation Date: 5/26/2014 2:02 PM
profile picture


I would like to backtest and optimize a simple Rotation strategy, but cannot seem to do it using Rules, and am not a programmer. I would appreciate if someone could either show me how to do it using Rules, or provide Code that would do it.

The strategy is as follows:

Rotate between two or more equities (say SPY and TLT).

Criteria for switching: Calculate a Ratio for each equity: Ratio = (Current Price)/(Price 85-Trading Days Ago). Whichever equity has the Highest Ratio, invest in that equity. Evaluate daily.

In addition to evaluating the strategy in general, I would like to be able to optimize the "#-Trading Days ago" factor; and also would like to experiment with evaluating weekly or monthly as well as daily, if possible.

Thank you for your help.

profile picture


Your ratio resembles ROC - actually ROC is the percentage change and this is the absolute number. For simplicity's sake, you can take the built-in RSI Rotation and tweak it like the FAQ suggests:

FAQ: I need other rotation rule other than the built-in RSI.
Please log in to see this code.

Or your ratio in absolute numbers would be:

Please log in to see this code.

...where Period should be set to 85. The period step and range can be adjusted, too:

Please log in to see this code.

Finally, run it in single symbol mode on a DataSet consisting of SPY and TLT. Obviously, you have to set the "n Symbols" to 1.