Nicolas

ZeroLag MACD

Category: Indicators By: Nicolas Created: October 26, 2015, 9:12 PM
October 26, 2015, 9:12 PM
Indicators
13 Comments
ZeroLag MACD

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"

 

Download
Filename: ZeroLag-MACD.itf
Downloads: 719
Nicolas
Nicolas Legend
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Alai-n
3 years ago
#

Afin d'avoir l'Histogramme Macd il faut rajouter ligne18 : HistogrammeMacd = ZeroLagMACD - SignalMACD (et dans le) Return HistogrammeMacd as "HistogrammeMacd"(ligne19)

Romina
4 years ago
#

Buenas tardes Nicolás, Estoy intenando configurar este indicador MACD Retraso 0, y no se que debo poner en "defina la siguiente variable: EMAshort1. Espero sus noticias. Muchas gracias

ginko
7 years ago
#

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.

Nicolas
7 years ago
#

The TEMA instruction is available, so that's easy to make an MACD with it. https://www.prorealcode.com/documentation/tema/

absent1980
10 years ago
#

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

Doctrading
10 years ago
#

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,

Lasse
10 years ago
#

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.

Lasse
10 years ago
#

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.

Nicolas
10 years ago
#

Hi Lasse, because MACD is a line and not an histogram for the indicator embedded in the platform.

smnjnssn
10 years ago
#

Hi.

Can you please describe how you set the colors as in the attached screenshot? Thanks.

sam00075
3 years ago
#

Hi Nicolas, can you please upload a version with TEMA, so those who don't know how to code can download the .itf ? Thanks

Nicolas
3 years ago
#

Use the MACD code here: https://www.prorealcode.com/topic/standard-prt-code-for-macd/#post-189640 and change exponentialaverage with TEMA see instruction: https://www.prorealcode.com/documentation/tema/

Nicolas
10 years ago
#

Just set the two colors of the 'SignalMACD' curve in the indicator properties window.

ProRealCode ProRealCode
Loading...