Skip to main content

ZeroLag MACD for Amibroker (AFL)

solwake about 16 years ago Amibroker (AFL)

  • Rating:
    3 / 5 (Votes 4)
  • Tags:
    oscillator, macd, amibroker, ZeroLag

ZeroLag MACD

MACD shows the difference between a fast and slow exponential moving average (EMA) of closing prices. Since it is based on moving averages, MACD is inherently a lagging indicator.

MACD is a form of Absolute Price Oscillator (APO), meaning that it takes the difference of two price EMAs. An alternate form of price oscillator is the Percentage Price Oscillator (PPO) which is computed by dividing the difference between two moving averages of price by the longer moving average value. The relative values generated by a PPO will differ from an APO (or MACD) in subtle but significant ways, and are preferred when (a) comparing the oscillator values between different securities, especially of widely different prices, or (b) comparing oscillator values for the same security at significantly different times, especially for a security whose value has changed greatly. The APO (and hence the MACD) will show greater oscillator extremes for higher priced securities, unlike the percentage price oscillator. The final member of the price oscillator family is the Detrended price oscillator.

Screenshots

Indicator / Formula

Copy & Paste Friendly
p1 = Param("Short period", 12, 3, 50, 1);
p2 = Param("Long period", 26, 5, 100, 1);
p3 = Param("Signal period", 9, 3, 25, 1);

EMAshort = EMA(C, p1);
EMA2 = EMA( EMAshort, p1);
Diff = EMAshort - EMA2;
ZLEMAshort = EMAshort + Diff;

EMAlong = EMA(C, p2);
EMA2 = EMA(EMAlong, p2);
Diff = EMAlong - EMA2;
ZLEMAlong = EMAlong + Diff;

ZLMACD = ZLEMAshort - ZLEMAlong;

EMA1 = EMA(ZLMACD, p3);
EMA2 = EMA(EMA1, p3);
Diff = EMA1 - EMA2;
ZLSignal = EMA1 + Diff;

Plot(ZLMACD, "zero lag MACD", colorGreen);
Plot(ZLSignal, "zero lag Signal", colorRed);

0 comments

Leave Comment

Please login here to leave a comment.