New to the platform and been a few years so coding is rusty; thanks in advance for your patience.  I'm looking to run at minute resolution and compare the highs and lows of the last 3 bars.  My searching has told me rolling windows is the best option for this, however it seems like I'm not getting the correct data or using them incorrectly.  When I run my code, I get a variabled referenced before assignment error.  I copied my code through the variable assignment below, I would assume the if statement is not being satisfied but am not sure why.  Any advice would be appreciated.

 

 

 

def Initialize(self):
        self.SetStartDate(2021, 1, 1)                                   #Starts Jan 1 2020
        self.SetEndDate(2021,2,3)                                       #Ends Today
        self.SetCash(1000)                                              #Thousand dollar balance
        self.spy = self.AddEquity("SPY", Resolution.Minute)             #Add SPY Minute Data
        self.spy.SetDataNormalizationMode(DataNormalizationMode.Raw)    #Set Data Normalization Mode
        self.SetWarmup(3)
        self.window = RollingWindow[TradeBar](3)
        self.lowWindow = RollingWindow[float](3)
        self.highWindow  = RollingWindow[float](3)
        

    def OnData(self, data):
        self.lowWindow.Add(data["SPY"].Low)
        self.highWindow.Add(data["SPY"].High)
        
        if self.highWindow.IsReady and self.lowWindow.IsReady:
            High = self.highWindow[0]
            Low = self.lowWindow[0]
            LastHigh = self.highWindow[1]
            LastLow = self.lowWindow[1]
            OldHigh = self.highWindow[2]
            OldLow = self.lowWindow[2]