Hi Mia, I have coded below to calculate RSI of TQQQ. However, I found that the RSI calculation may not be correct if coded in this way. If the period is short, like 2 or 3, the smoothing is much less than longer period. More history data and warmup should be done for RSI before use it. Could you help to modify the code? Thanks.

from AlgorithmImports import *

class TQQQRSI(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2018, 1, 1)
        self.SetCash(10000) 
        self.VOLA = 200
        res = Resolution.Daily
        
        self.SPY = self.AddEquity('SPY', Resolution.Minute).Symbol
        self.UVXY = self.AddEquity('UVXY', Resolution.Minute).Symbol
        self.TQQQ = self.AddEquity('TQQQ', Resolution.Minute).Symbol

        self.Securities["SPY"].SetDataNormalizationMode(DataNormalizationMode.Raw);
        self.Securities["UVXY"].SetDataNormalizationMode(DataNormalizationMode.Raw);
        self.Securities["TQQQ"].SetDataNormalizationMode(DataNormalizationMode.Raw);
        
        self.spySMA = self.SMA("SPY", 200, res)
        self.tqqqRSI = self.RSI("TQQQ", 10, MovingAverageType.Wilders, res)
        
        self.SetWarmUp(self.VOLA, res)
        
    def OnData(self, data):
        if not (self.Time.hour == 9 and self.Time.minute == 31): return  
        if not self.spySMA.IsReady:
            return
        if data.ContainsKey(self.SPY):
            spyclose = data[self.SPY].Close
        
            if spyclose > self.spySMA.Current.Value:
                if self.tqqqRSI.Current.Value > 79:
                    self.SetHoldings(self.TQQQ, 0.0)
                    self.SetHoldings(self.UVXY, 1.0)
                else:
                    self.SetHoldings(self.UVXY, 0.0)

                    self.SetHoldings(self.TQQQ, 1.0)
            else:
                    self.SetHoldings(self.UVXY, 0.0)
                    self.SetHoldings(self.TECL, 0.0)