Hello,

Im absolutely new to qc. However Im trying to make an algorithm that buys whenever the RSI is less than 28 and sells whenever its above 70. The issue is, that it never buys anything and it seems that the data is not even refreshin. 

Im really frustrated, what am I doing wrong?

 

class rsi_loop(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2021, 10, 10)  #Set Start Date
        self.SetEndDate(2021,10,18)
        self.SetCash(100)
        
        self.invested = 10

        # Set deposits
        #self.Schedule.On(self.DateRules.Every(DayOfWeek.Monday),self.TimeRules.At(12,00),self.OnData)
    
        # Set Brokerage Model 
        #self.SetBrokerageModel(BrokerageName.GDAX, AccountType.Cash)
        self.AddCrypto("BTCUSD", Resolution.Tick)
        
        self.btcusd = self.AddCrypto("BTCUSD", Resolution.Minute)
        
        RSI_period = 14
        self.RSI_ind_BTC = self.RSI(self.btcusd.Symbol,RSI_period,Resolution.Minute) 
        self.SetWarmUp(RSI_period)
        
        
        
        self.allowed_operations = 8
        self.quantity = (self.Portfolio.Cash / self.allowed_operations) 
        self.portions = (self.Portfolio.Cash / self.allowed_operations) / self.Portfolio.Cash
        
        #initializing variables
        self.btc_longoper = True
        
        
        # Create our rolling windows
        #self.tradeBarWindow = RollingWindow[TradeBar](5) # Store the last 5 values 
        #self.rsiWindow = RollingWindow[Decimal](10) # Store the last 10 values

    def OnData(self, data):
        

        if not self.RSI_ind_BTC.IsReady:
            return
        
        if not self.Portfolio.Invested and self.RSI_ind_BTC.Current.Value < 28 and self.btc_longoper == True:
            quantity = self.CalculateOrderQuantity(self.btcusd.Symbol, 0.5)
            self.MarketOrder(self.btcusd.Symbol,quantity)
            #self.SetHoldings(self.btcusd.Symbol,0.5)
            self.Debug("RSI < 30, Buying")
            self.btc_longoper = False
            
        if self.btc_longoper == False and self.RSI_ind_BTC.Current.Value > 70:
            self.Liquidate()
            
        self.Plot("Indicators","RSI", self.RSI_ind_BTC.Current.Value)   
        

Author