Hi everyone, I am trying to gain some experience on QuantConnect and I am currently trying to develop a Range Trading algorithm. I am quite sure it's not working and I think the main problem is the short selling. I am not even sure if the StopLoss and TakeProfit are set up correctly. Here's the code:

class Strategy(QCAlgorithm):
    
    def Initialize(self):
        self.SetStartDate(2022, 1, 1)
        self.SetEndDate(2022, 1, 31)
        self.SetCash(100000)
        self.stock = self.AddEquity("TSLA", Resolution.Minute)
        
        self.Max = self.MAX("TSLA", 60, Resolution.Minute)
        self.Min = self.MIN("TSLA", 60, Resolution.Minute)
        self.SetWarmUp(60, Resolution.Minute)

        consolidator = TradeBarConsolidator(TimeSpan.FromMinutes(15))  ## Selected resolution is hourly, so this will create a 6-hour consolidator
        consolidator.DataConsolidated += self.OnDataConsolidated  ## Tell consolidator which function to run at consolidation intervals
        self.SubscriptionManager.AddConsolidator("TSLA", consolidator)  ## Add consolidator to algorithm

    def OnData(self, data):
        pass

    def OnDataConsolidated(self, sender, bar):
        
        # if self.IsWarmingUp or not (self.Max.IsReady and self.Min.IsReady):
        #     return
    
        Min = 0
        Max = 0
        
        Close = self.Securities["TSLA"].Close
        stopPrice = Close * 0.99
        limitPrice = Close * 1.01
        
        if self.Max.IsReady and self.Min.IsReady:
            Min = self.Min.Current.Value
            Max = self.Max.Current.Value

        if Close >= Max:
            self.MarketOrder("TSLA", 10)
            # self.StopLimitOrder("TSLA", 10, stopPrice, limitPrice)
            
        elif Close < Min:
            self.MarketOrder("TSLA", -10)
            # self.StopLimitOrder("TSLA", 10, stopPrice, limitPrice)
            
        self.StopLimitOrder("TSLA", 10, stopPrice, limitPrice)

I am quite sure it's not short selling. Does anyone have any idea?

Thanks

Author