Hi all,

I am just getting started with Quantconnect. I have some experience with programming, but not with Python. This combination makes for a steep learning curve! The following code is not a serious algorithm, rather an attempt at getting everything working. The problem is, I get a syntax error at the first if statement. I cannot, for the life of me, see why. I'm sure this is a basic noob error, and I would be very grateful if someone could point me in the right direction.

Kind regards
Richard

class HyperActiveAsparagusAlligator(QCAlgorithm):
   
   self.ratioEarliest = none
   self.ratioMiddle = none
   self.ratioLatest = none

   def Initialize(self):
       self.SetStartDate(2019, 1, 3)
       self.SetEndDate(2021, 1, 3)
       self.SetCash(100000)
       spy = self.AddEquity("SPY", Resolution.Daily)
       spy.SetDataNormalizationMode(DataNormalizationMode.Raw)
       aapl = self.AddEquity("PEP", Resolution.Daily)
       aapl.SetDataNormalizationMode(DataNormalizationMode.Raw)

 

   def OnData(self, data):
       
  
       self.Ratio = self.Securities["SPY"].Price / self.Securities["PEP"].Price
       # self.Debug (self.Ratio)
       
       #Update the 3 ratio variables
       self.ratioEarliest = self.ratioMiddle
       self.ratioMiddle = self.ratioLatest
       self.ratioLatest = self.ratio
       
       #Plot the ratio
       self.Plot("Data Chart", "Ratio", self.Ratio)
       #self.Plot("Data Chart", "Asset Price", data["AAPL"].Close)
    
       #If ratio has increased 3 times, sell a and buy b
       If self.ratioEarliest < self.ratioMiddle and If self.ratioMiddle < self.ratioLatest:
           #check that there has been a 3 down since the last buy
           #sell a and buy b
           self.MarketOrder("SPY", 100)
           self.MarketOrder("PEP", -100)
               
       #If ratio has decreased 3 times, buy a and sell b
       If self.ratioEarliest > self.ratioMiddle and If self.ratioMiddle > self.ratioLatest:
               #check that 1 day has passed since last trade
               #check that there has been a 3 up since the last buy
               #buy a and sell b
               self.MarketOrder("SPY", -100)
               self.MarketOrder("PEP", 100)