I'm pretty new to coding and I am trying to write my own MACD difference value in python (because I couldn't find one in the git repository).

I'm using the sample MACD code MACDTrendAlgorithm.py which can be found here https://github.com/trooper5010/Lean/blob/master/Algorithm.Python/MACDTrendAlgorithm.py

I am trying to create a MACD Difference which takes the difference between MACD and its moving average and a MACD Previous Difference which takes the previous value of the MACD difference after the hour has closed. However, I don't know how to do MACD previous in terms of objects and attributes. Here is what I have so far:

# define MACD Difference and Previous Difference Diff = (self.__macd.Current.Value - self.__macd.MovingAverageType.Current.Value) Diffprev = self.__macd.

 

I'm fairly new to coding so I'm not sure what to do from here whether that means create an attribute for what I need or if there is already one in the repository.
Thanks for your help.