Here is the traditionnal MACD (Moving Average Convergence Divergence) indicator made with the “zero lag” calculation process.
The default values are : 26 (long) , 12 (short) and 9 for the signal line.
EMAshort1 = exponentialaverage[short](close)
EMAshort2 = exponentialaverage[short](EMAshort1)
DifferenceShort = EMAshort1 - EMAshort2
ZeroLagShort = EMAshort1 + DifferenceShort
EMAlong1 = exponentialaverage[long](close)
EMAlong2 = exponentialaverage[long](EMAlong1)
DifferenceLong = EMAlong1 - EMAlong2
ZeroLagLong = EMAlong1 + DifferenceLong
ZeroLagMACD = ZeroLagShort - ZeroLagLong
signal1=ExponentialAverage[signal](ZEROLAGMACD)
signal2=ExponentialAverage[signal](signal1)
DIFFERENCE2=signal1-signal2
SignalMACD=signal1+DIFFERENCE2
RETURN ZeroLagMACD as "Zero Lag MACD", SignalMACD as "Signal MACD"
You must be logged in to post a comment.
There are 2 versions of the MACD (almost) Zero Lag in the same Article introducing Zero-Lag MACD, (Patrick G. Mulloy), "Smoothing Data With Less Lag" article in TASC (Technical Analysis of Stock and Commodities) V12.2 pages 72-80. One version is indeed using a DEMA as shown in the code above, the second version in the article used a TEMA instead. Only the DEMA version is implemented in ProrealTime. The TEMA is faster (and has even less lag), BTW: Both versions are not truly zero-lag, but are "almost" zero-lag. Patrick Murphy stated that "Comparing the MACDs for TEMA1 with DEMA1" ... "The DEMA1 MACD had two fewer trades, approximately a 20% improvement in overall profit, and one fewer drawdown." But he stated that with other period parameters, TEMA version was way better and showed a 50% improvement in overall profit vs the DEMA version. Please refer to the article for more clues.
Hi,
How to build this into the system as a condition such as: "IF MACDZeroLag > MACDZeroLag[1] THEN ..." When i call for this indicator probuilder shows an error because only one value out of three is used.
Thanks
Hello,
Here is a code with the same result as default indicator :
// MACD ZERO LAG
// p= variable macd zerolag : 12 par défaut
// q= variable signal : 26 par défaut
// r= variable macd - signal : 9 par défaut // mettre histogramme
p = 12
q = 26
r = 9
z1=DEMA[p](close)
z2 =dema[q](close)
e= z1 - z2
z3=DEMA[r](e)
f=z3
g=e-f
return e AS "MACD ZEROLAG",f AS "signal",g as "macd-signal",0 as "zero"
Best regards,
ok, but even though I look at the line and compare it with the histogram in the default indicator it is still not the same result - ...not really sure what you mean. What I am looking for, is a coding for the MACD Zero lag indicator in order to apply it as part of my proscreenings. Could you please post the link to the indicator codings if it's available? thanks.
Hi Nicolas,
When applying these codes for MACD zero lag above I don't get the same result as the stadard MACD zero lag indicator embedded in the system, please see picture attached. Do you know what I am doing wrong? For this example I am using standard periods - 12/26/9. I am looking for the codes for MACD zero lag indicator in order to use it in the proscreener. thanks.
Afin d'avoir l'Histogramme Macd il faut rajouter ligne18 : HistogrammeMacd = ZeroLagMACD - SignalMACD (et dans le) Return HistogrammeMacd as "HistogrammeMacd"(ligne19)