Hi all,

New to QC and Python here. I'm working on an algo based off of the work of JDMar here: 

https://www.quantconnect.com/forum/discussion/4440/an-intermarket-approach-to-beta-rotation

The idea is to use the ratio of RSI indicators on an asset and its benchmark over the past 4 weeks and to hold the asset (benchmark) if the ratio is greater (less than) 1. The original author chooses just two assets to trade (XLU ande VTI) but I'd like to extend the functionality to choose form multiple sector ETFs. 

Approach I'm using is based off this tutorial example but I'm stuck at creating the custom indicator. I've created a class SymbolData and using a loop (line 62) to initialise the indicator like this, but am confused on the syntax to define the ratio of the two indicators. I'm thinking it should look something like the below but I'm not clear how to plug in the the second argument of IndicatorExtensions.Over() for the RSI of my benchmark (e.g. if I chose SPY as one of my Symbols at a previous step, so the SPY RSI indicator has already been initialised)

https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/MultipleSymbolConsolidationAlgorithm.py

 

# loop through all our symbols and initialize indicator for symbol, symbolData in self.Data.items(): # define RSI symbolData.RSI = RelativeStrengthIndex(self.CreateIndicatorName(symbol, "RSI" + str(RollingWindowSize), self.resolution),RollingWindowSize, MovingAverageType.Simple) # define relative RSI for symbol, symbolData in self.Data.items(): # RSI of ETF / RSI Benchmark symbolData.relRSI = IndicatorExtensions.Over(symbolData.RSI,????????)

 

 

Author