I am trying to run the below code but cannot get pass the build stage (error: Cannot get rid of this error: Build Error: File: n/a Line:0 Column:0 - Python class failed to compile)

Any suggestions on why this error is occurring? Seems to be random.


class PriceCrossingEMA(QCAlgorithm):
    
    def Initialize(self):
        self.SetStartDate(2017, 1, 1)
        self.SetEndDate(2021, 12, 31)
        self.SetCash(100000)
        
        self.symbol = self.AddEquity("QQQ", Resolution.Minute).Symbol
        self.Consolidate(self.symbol, timedelta(minutes=5), self.BarHandler)
        
        self.emaShort = self.EMA(self.symbol, 50, Resolution.Minute)
        self.RegisterIndicator(self.symbol, self.emaShort, timedelta(minutes=5))
        
        self.emaLong = self.EMA(self.symbol, 200, Resolution.Minute)
        self.RegisterIndicator(self.symbol, self.emaLong, timedelta(minutes=5))

        self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage)
        
        self.lastEmaShort = None
        self.lastEmaLong = None
        self.lastPriceHigh = None
        self.lastPriceLow = None
        self.lastPriceClose = None

    def OnData(self, data):

        if not self.emaLong.IsReady:
            return

        if self.lastEmaShort is None         \
            or self.lastEmaLong is None      \
            or self.lastPriceHigh is None    \  
            or self.lastPriceLow is None     \
            or self.lastPriceClose is None:
                self.lastEmaShort = self.emaShort.Current.Value
                self.lastEmaLong = self.emaLong.Current.Value
                self.lastPriceHigh = self.Securities[self.symbol].High
                self.lastPriceLow = self.Securities[self.symbol].Low
                self.lastPriceClose = self.Securities[self.symbol].Close
        
        if not self.Portfolio.Invested:
            #price crossing over/down EMA Long
            if self.lastPriceClose > self.lastEmaLong and self.Securities[self.symbol].Close < self.emaLong.Current.Value:
                self.SetHoldings(self.symbol, -1)
                self.stopPrice = self.Securities[self.symbol].High
                self.tradeQuantity = self.Portfolio[self.symbol].Quantity
                self.StopMarketOrder(self.symbol, self.tradeQuantity, self.stopPrice)
            
            #price crossing over/up EMA Long
            elif self.lastPriceClose < self.lastEmaLong and self.Securities[self.symbol].Close > self.emaLong.Current.Value:
                self.SetHoldings(self.symbol, 1)
                self.stopPrice = self.Securities[self.symbol].Low
                self.tradeQuantity = self.Portfolio[self.symbol].Quantity
                self.StopMarketOrder(self.symbol, -self.tradeQuantity, self.stopPrice)
                
        if self.Portfolio[self.symbol].IsShort:
            if self.Securities[self.symbol].Close > self.emaShort.Current.Value:
                self.Transactions.CancelOpenOrders()
                self.Liquidate()
            
        elif self.Portfolio[self.symbol].IsLong:
            if self.Securities[self.symbol].Close < self.emaShort.Current.Value:
                self.Transactions.CancelOpenOrders()
                self.Liquidate()

        self.lastEmaShort = self.emaShort.Current.Value
        self.lastEmaLong = self.emaLong.Current.Value
        self.lastPriceHigh = self.Securities[self.symbol].High
        self.lastPriceLow = self.Securities[self.symbol].Low
        self.lastPriceClose = self.Securities[self.symbol].Close

    def BarHandler(self, consolidated):
        return
    
    #def OnOrderEvent(self, orderEvent):
    #    if orderEvent.Status == OrderStatus.Filled: