Hi all,
I am relatively new to Python and trying to play around to understand how to build an algorithm.

I have a really simple question, but dont understand why I cannot figure this out.

 

This part:

        if self.macd > 0:
            self.Debug(str("macd is over 0"))

is causing me alot of headache. Why is this not working when I have a variable > 0 in the if formula? I have tried to change it from self.macd to other variables without success. but replacing the variable with a number, like numer 1 would work.

Would anyone know why and help me out with this?

Appreciate the help!

class BasicTemplateAlgorithm(QCAlgorithm): def Initialize(self): self.SetStartDate(2017,01,01) #Set Start Date self.SetEndDate(2017,10,10) #Set End Date self.SetCash(10000) #Set Strategy Cash self.AddEquity("TSLA", Resolution.Daily) self.smaFast = self.SMA("TSLA", 10, Resolution.Daily); self.smaSlow = self.SMA("TSLA", 20, Resolution.Daily); self.macd = self.MACD("TSLA", 12, 26, 9); def OnData(self, data): #self.Debug(str(self.macd)) if self.smaFast > self.smaSlow: self.SetHoldings("TSLA", 1) elif self.smaFast < self.smaSlow: self.SetHoldings("TSLA", 0) if self.macd > 0: self.Debug(str("macd is over 0"))