need help with calculation of zero lag macd

 

Hello everyone!

I need the values of MACD calculated like they are in the ZeroLAG MACD indicator

"ZeroLAG MACD calculates on formula:"

ZeroLAG MACD(i) = (2*EMA(Close, FP, i) - EMA(EMA(Close, FP, i), FP, i)) - (2*EMA(Close, SP, i) - EMA(EMA(Close, SP, i), SP, i));

ZeroLAG MACD Signal(i) = 2*EMA(ZeroLAG MACD(i), SigP, i) - EMA(EMA(ZeroLAG MACD(i), SigP, i), SigP, i);

where:
EMA - exponential moving average;
Close - a price of the closing of the bar;
FP - a period of the quick moving average;
SP - a period of the slow moving average;

SigP - a period of the signal moving average;


I don´t know how to programm an EMA of an EMA. An option would be to use icustom and to receive the values frome the indicator, but I need to understand the calculation for using it in my EA.

Thanks in advance!

 

Probably I need to put the EMA into an array and then calculate the EMA of it with iMAOnArray

https://docs.mql4.com/indicators/iMAOnArray

Reason: