Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-0.869
Tracking Error
0.271
Treynor Ratio
0
Total Fees
$0.00
Estimated Strategy Capacity
$0
# Stochastic RSI Indicator

STOCK = "SPY"; RSI_PERIOD = 14; STO_PERIOD = 20;

class StochasticRSI(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 1, 1)  
        self.SetEndDate(2021, 4, 30)
        self.SetCash(10000)
        self.stock  = self.AddEquity(STOCK, Resolution.Daily).Symbol 
        self.SetWarmUp(RSI_PERIOD + STO_PERIOD + 10)
        
        self.rsi = self.RSI(self.stock, RSI_PERIOD, Resolution.Daily) 
        self.stoch = self.STO(self.stock, STO_PERIOD)  # FastStoch, StochK, StochD
        self.rsi.Updated += self.consolidation_handler
        
        
    def consolidation_handler(self, sender, bar):
        if self.rsi.IsReady:
            rsi = self.rsi.Current.Value
            trade_bar = TradeBar(bar.EndTime, self.stock, rsi, rsi, rsi, rsi, 0)
            self.stoch.Update(trade_bar)
            

    def OnData(self, data):
        if self.IsWarmingUp or not self.stoch: return 

        self.Plot("Indicator", "StochRSI_FastK", self.stoch.FastStoch.Current.Value)
        self.Plot("Indicator", "StochRSI_SlowK", self.stoch.StochK.Current.Value)