I am trying a really basic MACD Alpha model using the algo framework and I see some errors in insights time compared to Yahoo finance or spreadsheet calculated MACD. Maybe I am just beginning and missing something really obvious, can you help me to make it work ?


I checked that Resolution was daily for both Alpha model and Yahoo finance.

I tried both MovingAverageType.Simple and MovingAverageType.Exponential in addAlpha arguments.

Example of insights


Example of yahoo finance MACD



from Alphas.MacdAlphaModel import MacdAlphaModel

class PrototypeV0(QCAlgorithm):

def Initialize(self):

self.UniverseSettings.Resolution = Resolution.Minute
self.UniverseSettings.DataNormalizationMode = DataNormalizationMode.Raw

self.SetStartDate(2017, 2, 15)


symbols = [ Symbol.Create("TSLA", SecurityType.Equity, Market.USA)]

self.AddAlpha(MacdAlphaModel(12, 26, 9, MovingAverageType.Exponential, Resolution.Daily))

self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel() )

self.SetExecution( ImmediateExecutionModel() )


def OnData(self, data):
'''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.
data: Slice object keyed by symbol containing the stock data

# if not self.Portfolio.Invested:
# self.SetHoldings("SPY", 1)