Hi everyone, I am new to QuantConnect. I am trying to build up a sort of Range Trading algorithm but I keep receiving an error. My code is:

class Strategy(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2018, 1, 1)
        self.SetEndDate(2021, 1, 1)
        self.SetCash(100000)
        self.AddEquity("TSLA", Resolution.Minute)

        self.Max = self.MAX("TSLA", 60, Resolution.Minute)
        self.Min = self.MIN("TSLA", 60, Resolution.Minute)
        
        
    def OnData(self, data):
        
        Close = self.Securities["TSLA"].Close
        stopPrice = Close * 0.99
        limitPrice = Close * 1.01
        Min = self.Min
        Max = self.Max
        
        if Close > Max:
            self.MarketOrder("TSLA", 10)
            self.StopLimitOrder("TSLA", 100, stopPrice, limitPrice)
            
        elif Close < Min:
            self.MarketOrder("TSLA", 10)
            self.StopLimitOrder("TSLA", 100, stopPrice, limitPrice)
            

And the error is:

Runtime Error: TypeError : Cannot get managed object
  at OnData
    if Close > Max:
===
   at Python.Runtime.PyObject.Invoke(PyTuple args in main.py: line 27
	 (Open Stacktrace)

I can't really figure it out.