I'm trying to build a variation of the opening range break but seems as though my orders are not working. Would anyone know why? I'm fairly new to coding so might be missing something somewhere.

# First 30 minutes Highest High and Lowest Low

# -------------------------
STOCK = "SPY"; PERIOD = 30;
# -------------------------

class OpeningRangeBreakout(QCAlgorithm):
    
    # Order ticket for our stop order, Datetime when stop order was last hit
    stopMarketTicket = None
    stopMarketOrderFillTime = datetime.min
    highestSPYPrice = 0

    def Initialize(self):
        self.SetStartDate(2021, 9, 1)  
        self.SetEndDate(2021, 9, 10)  
        self.SetCash(100000) 
        self.stock = self.AddEquity(STOCK, Resolution.Minute).Symbol
        self.max = self.MAX(self.stock, PERIOD, Resolution.Minute, Field.High)
        self.min = self.MIN(self.stock, PERIOD, Resolution.Minute, Field.Low)
        self.SetWarmUp(PERIOD, Resolution.Minute)
        

    def OnData(self, data):
        # # 1. Plot the current SPY price to "Data Chart" on series "Asset Price"
        # self.Plot("Data Chart", "Asset Price", self.Securities["SPY"].Close)
        
        if self.IsWarmingUp: 
            return
        if not (self.max.IsReady or self.mi.IsReady): 
            return
        if self.Time.hour < 10 or self.Time.hour > 10 or self.Time.minute != 31: 
            return

        first_30_min_HH = self.max.Current.Value
        first_30_min_LL = self.min.Current.Value

        self.Log(f"First 30 min Highest High: {first_30_min_HH}")
        self.Log(f"First 30 min Lowest Low: {first_30_min_LL}")
        
        self.Plot("Data Chart", 'first_30_min_HH', first_30_min_HH)
        self.Plot("Data Chart", 'first_30_min_LL', first_30_min_LL)
        
        if not self.Portfolio.Invested:
            if data["SPY"].Close > first_30_min_HH:
                self.MarketOrder("SPY", 500)
                self.stopMarketTicket = self.StopMarketOrder("SPY", -500, 0.99 * self.Securities["SPY"].High)
                
            elif data["SPY"].Close < first_30_min_LL:
                self.MarketOrder("SPY", -500)
                self.stopMarketTicket = self.StopMarketOrder("SPY", +500, 1.01 * self.Securities["SPY"].Low)
        
        else:
            #2. Plot the moving stop price on "Data Chart" with "Stop Price" series name
            self.Plot("Data Chart", "Stop Price",  self.highestSPYPrice * 0.9)
            
            if self.Securities["SPY"].High > self.highestSPYPrice:
                #2. Save the new high to highestSPYPrice; then update the stop price to 90% of highestSPYPrice
                self.highestSPYPrice = self.Securities["SPY"].High
                updateFields = UpdateOrderFields()
                updateFields.StopPrice = self.highestSPYPrice * 0.99
                self.stopMarketTicket.Update(updateFields)
                
                #3. Print the new stop price with Debug()
                self.Debug("SPY: " + str(self.highestSPYPrice) + " Stop: " + str(updateFields.StopPrice)) 
            
    def OnOrderEvent(self, orderEvent):
        if orderEvent.Status != OrderStatus.Filled:
            return
        if self.stopMarketTicket is not None and self.stopMarketTicket.OrderId == orderEvent.OrderId:
            self.stopMarketOrderFillTime = self.Time