This code snippet demonstrates how to implement a Zero-Lag Moving Average Convergence Divergence (MACD) indicator using the ProBuilder programming language. The Zero-Lag MACD aims to reduce the lag associated with standard MACD calculations by using Double Exponential Moving Averages (DEMA).
defparam drawonlastbaronly=true
x = close
//Calcul DEMA[12]
indic1 = ExponentialAverage[12](close)
indic2 = ExponentialAverage[12](indic1)
A = indic1[1]
B = indic2[1]
Lox = 264*A-143*B
//Calcul DEMA[26]
indic3 = ExponentialAverage[26](close)
indic4 = ExponentialAverage[26](indic3)
C = indic3[1]
D = indic4[1]
Fast = 1300*C-675*D
//Calcul MACD ZERO LAG bougie courante
e = x*(17416/123201)+264/169*A-11/13*B-1300/729*C+25/27*D
//Calcul DEMA[9](e)
indic5 = ExponentialAverage[9](e)
indic6 = ExponentialAverage[9](indic5)
I = indic5[1]
J = indic6[1]
Sign = 144*I-80*J
//Calcul MACD ZEROLAG bougie[1]
z11 = DEMA[12](close)
z22 = DEMA[26](close)
f = z11[1] – z22[1]
//Calcul de y pour que MACD ZR – MACDZR[1] = 0 soit e – f =0
y = (f*123201+169*Fast-729*Lox)/17416
//Calcul de z pour que MACD ZR – Signal soit e = z3
z = (9*Lox/4225-36*Fast/72900+Sign/100-264/169*A+11/13*B+1300/729*C-25/27*D)/(17416/123201-435400/8555625)
//Renvoie la valeur de y pour e = flag
DRAWTEXT(” ———- #z# MACD ZeroLag Reverse”,barindex,y,dialog,standard,13) coloured(204,0,0)
DRAWTEXT(” ———- #z# MACD Signal Reverse”,barindex,z,dialog,standard,13) coloured(51,204,0)
return
The code snippet above is structured into several key sections:
This example is useful for understanding advanced financial indicator calculations and their implementation in trading systems using ProBuilder.
Check out this related content for more information:
https://www.prorealcode.com/topic/formulation-ema/page/3/#post-96554
Visit Link