The Moving Average Convergence Divergence (MACD) indicator created by Gerald Appel in 1979 (1) is part of the pantheon of technical indicators, being one of the most used and influential ever created. The popularity of the MACD allowed further studies and more varied applications of the indicator, from signal processing in neuroscience (2), prediction of hospitalizations (3)...etc.

In this post, we will highlight extensive details, calculations, and usages of this legendary indicator. If you wanted to go beyond what you learned about the MACD, then this post is for you.

This oscillator returns 3 time-series, the MACD, obtained from the difference between two exponential moving averages of different periods, a signal line, obtained from the exponential moving average of the MACD, and a histogram obtained from the difference between the MACD and the signal line.

Each MACD component allows evaluating the current market trend direction, momentum, and acceleration. Many traders believe the amount of information the MACD can return is sufficient to be used as a standalone for both trend-following and contrarian trading.

In terms of digital signal processing, the MACD can be classified as an infinite impulse response (IIR) bandpass filter, filtering out both lower and higher frequency components of a signal, thus having the ability to both detrend and smooth. The MACD filter satisfies the conditions for being a discreet time linear time-invariant (DLTI) system, it is linear and time-invariant:

The MACD oscillator is obtained from the difference of two exponential moving averages (ExpMA), one using a faster period (often 12) and one using a slower period (often 26).

We can also obtain the MACD from the following difference equation:

where

The impulse response of the MACD is the result obtained by applying the MACD to a unit impulse signal, given by the Kronecker delta function

The impulse response fully describes the properties of the MACD and can be obtained from the difference between the impulse response of two ema's with periods

The impulse response of an exponential moving average

As such for the impulse response of the MACD

Like with an exponential moving average, the impulse response of the MACD does not become steady, instead continuing indefinitely, hence why it is classified as an

The frequency response of filters allows us to determine how they affect the frequency content of a signal. The frequency response can be directly obtained from the discrete-time Fourier transform (DTFT) of the impulse response, which for the MACD returns:

with

It is generally more common to evaluate the filter transfer function

With feed-forward coefficient

This is the reverse ordering used by the MACD difference equation previously described, as such the MACD transfer function is given by:

The frequency response is then obtained by evaluating the above transfer function for

The magnitude response describes how a filter attenuates the amplitude of the frequencies composing a signal. It is obtained from the absolute value of the transfer function

For the MACD we obtain the closed-form solution:

with

In the previous figure we can see the magnitude response of the MACD using

The above figure shows various MACD magnitude responses for various configurations of the

The MACD has known a wide variety of usages amongst traders, extending from trend-following to contrarian methodologies.

The most basic usage of the MACD is given by evaluating the sign of the MACD, with a positive sign (fast ExpMa > slow ExpMA) indicating an uptrend and a negative sign (fast ExpMa < slow ExpMA) indicating a downtrend. We can see that this usage does not differ from the one given by a simple MA cross strategy. The user might also suffer from the excessive lag produced by this simplistic approach.

The strength of the indicator can come from the usage of the MACD with the signal line and histogram. A timelier approach would identify an uptrend when the MACD is above its signal line (histogram above 0) and a downtrend when the MACD is under the signal line (histogram under 0). This approach makes better use of the leading characteristic of the MACD oscillator, thus offering more predictive insights. However, an increment in timing does not come at no cost, with the more recurrent of whipsaw trades.

Notice in the image above how the usage of the MACD with the signal line allows for a faster trend detection compared to using the MACD alone. We can also see how this usage of the indicator is more sensitive to shorter-term price variations, inducing potential whipsaw trades. This is caused by the common tendencies that oscillators have to increase the presence of noise in an input series.

It is also possible to use a combination of both usages in order to avoid their disadvantages, for example opening trades based on the sign of the MACD while exiting trades when the MACD crosses the signal line. However, the main disadvantage of using the histogram can appear when the user must optimize indicator settings, with a usage based only on the MACD meaning that two settings would need to be optimized, while usage based on the histogram would mean optimizing three settings, which is computationally more expensive.

Divergences are commonly used with oscillators. A divergence occurs when the price tops/bottoms and MACD tops/bottoms are negatively correlated. This can indicate a trend impulse of lower amplitude, which could highlight a potential reversal.

The MACD already possesses some leading characteristics, allowing to anticipate turning points. However, the ability of the MACD to provide signals anticipating future trends mostly depends on the current market conditions, with certain price variations complicating the leading ability of the MACD. The predictive abilities of the MACD can be improved using a

Assuming the user uses the histogram of the MACD, cyclical variations within a price trend will generally prove to be problematic if the signal length excessively delays the MACD. Inverting the

The practice of inverting MACD fast and slow period was proposed by Ehlers (4), we can also see that optimizing MACD settings in mean reverting markets can tend to return

The MACD uses exponential for the calculation of the fast, slow, and signal moving averages by default, however different types of moving averages can be used. The MACD would directly inherit the characteristics of the type of moving average used, thus improving characteristics such as reactivity and smoothness.

For example, certain users prefer using the simple moving average, returning slightly lower reactive MACD with a slightly higher degree of filtering.

Using low lag moving averages would return a very reactive MACD, with a histogram able to anticipate MACD turning points due to the ability of low lag moving averages to over/undershoot the input signal.

Notice in the above chart how the MACD based on the Hull moving average (bottom) is more reactive than a regular MACD (top) with equal settings. Also, notice how the signal line is able to exceed the MACD before the occurrence of its turning point.

However, it can be more interesting to use more than one kind of moving averages for the MACD calculation, using a type of moving average that is suitable for each MACD component. As such it would be more interesting to have a low lag moving average as fast-moving average, and a more classical one as slow and signal moving average.

(1) Appel, Gerald. "Technical Analysis Power Tools for Active Investors." Financial Times Prentice Hall. p. 166 (2005)

(2) Durantin, Gautier, et al. "Moving Average Convergence Divergence filter preprocessing for real-time event-related peak activity onset detection: Application to fNIRS signals." 2014 36th Annual International Conference of the IEEE Engineering in Medicine and Biology Society. IEEE, 2014.

(3) Zhang, Jufen, et al. "Predicting hospitalization due to worsening heart failure using daily weight measurement: analysis of the Trans‐European Network‐Home‐Care Management System (TEN‐HMS) study." European journal of heart failure 11.4 (2009): 420-427.

(4) Ehlers, John F. "The MACD Indicator Revisited." (1991).

Get access to our exclusive tools: luxalgo.com

Join our 150k+ community: discord.gg/lux

All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.

Join our 150k+ community: discord.gg/lux

All content provided by LuxAlgo is for informational & educational purposes only. Past performance does not guarantee future results.

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.