Hello, I am working on a new algorithm using the MACD indicator and it's values, and I have yet in backtests to take any trades, and debugging always gives an MACD value of 0.0. I am using self.var.Current.Value and for the Signal, self.var.Signal.Current.Value, all on minute resolution. I have cloned multiple examples from documentation and elsewhere, still getting no trades and a value of 0.0 when debugging, but I will still post my code just in case.

def Initialize(self): self.SetStartDate(2021, 1, 1) self.SetCash(1000000) self.AddEquity('SPY') self.SetBenchmark('SPY') self.SetBrokerageModel(AlphaStreamsBrokerageModel()) self.SetExecution(ImmediateExecutionModel()) self.SetRiskManagement(MaximumDrawdownPercentPerSecurity(0.05)) self.AddSecurity("TQQQ", Resolution.Minute) self.macA = self.MACD("TQQQ", 12, 26, 9, MovingAverageType.Exponential, Resolution.Minute) self.SetWarmup(26) def OnData(self, data): if self.IsWarmingUp: return if self.macA.Current.Value < 0: if self.macA.Signal.Current.Value < self.macA.Current.Value: self.SetHoldings("TQQQ", .1)

 

Author