Introduction :

MACD stands for Moving Average Convergence Divergence. It is a momentum class of Indicator. Gerald Apple, a well renowned Technical and Quantitative analyst introduced the indicator in 1970s.

Illustration 1 : MACD indicator

MACD indicator itself consists of 3 time series calculations namely the MACD line, the Signal line and the MACD Histogram. We will be discussing the calculations behind the MACD indicator, the different ways in which signals can be generated using the MACD indicator and in the end we will create and backtest some strategies using the MACD indicator on the Streak.world platform.

How are each of the series calculated ? :

As all other indicators, MACD is calculated from price data. MACD takes in three parameters. The default parameters for MACD are 12, 26, 9.

12 represents a 12 period EMA of the price and 26 represents 26 period EMA of the Price. We will cover the parameter ‘9’ in a while as we need to understand the 1st 2 parameters clearly.

(A) MACD Line :

The MACD line is calculated by subtracting the 26 period EMA from the 12 Period EMA which means it basically represents the separation between Fast and Slow EMAs. The MACD line keeps oscillating between the 0 level. When both, the 12 & 26 period EMA become same at a particular candle, the value of the MACD becomes 0. When EMA 12 is above EMA 26, the value of MACD is Positive similarly when EMA 12 is below EMA 26, the value of MACD is negative. If the MACD keeps rising, it indicates that the fast EMA is moving away from the slow EMA.

A very interesting thing to note here is that MACD indicator alone can be used to trade a two moving average trading system simply by checking for the zero line crossover as MACD crossing above the zero line essentially indicates that the faster moving average (default value 12 EMA) is crossing above slower moving average (default value 26 EMA).

(B) MACD Signal Line

MACD Signal line is simply a smoothed MACD line. Moving average is applied to the MACD line itself to calculate the MACD Signal line. By default, a 9 period EMA of the MACD line is used and this is the 3rd parameter of MACD which we discussed earlier.

(C ) MACD Histogram

MACD Histogram represents the separation between the MACD line and MACD signal line. It is calculated by Subtracting the MACD signal line from the MACD line.

Like MACD line, MACD also keeps oscillating between the zero line. When the Histogram is above the zero line, it implies that the MACD line is above the MACD signal line. Similarly, if the MACD histogram is below the zero line, it implies that the MACD is below the MACD signal line. The color of the histogram bars depends if the histogram is rising or falling. If the value of histogram is higher than the previous histogram bar, it is shown in green color and if the value of the histogram is lower than the value of histogram prior to it, the histogram bar is represented in red color. All the charting platforms do not follow the same color convention but most of them do.

Generating Trade Signals using the MACD Indicator :

Until now we have covered the calculation part of the MACD indicator. Now lets go ahead and see what various ways are used to generate signals with the MACD indicator.

(i) Using the MACD line crossover with the MACD signal Line

Bullish : MACD line crossing above the the MACD signal line.

Bearish : MACD line crossing below the MACD signal line.

(ii) Using the MACD line crossover with the Zero Line

Bullish : MACD line crossing above the 0 line.

Bearish : MACD line crossing below the 0 line.

(iii) Using the MACD Histogram crossover

Bullish : MACD histogram crossing above the 0 line

Bearish : MACD histogram crossing below the 0 line.

(iv) Using Divergence with the Price

There are two ways to check divergence with the MACD indicator. One is the Price and MACD line divergence and the other is Price and MACD histogram divergence. As divergence is a huge topic in itself, we will cover divergence in detail in our upcoming posts.

Backtesting Strategies with the MACD indicator :

Below are results of a simple strategy which has been backtested on NVIDIA, Nike, MTD Products, Lowe’s Companies Inc and Eliy Lilly and Co. traded on NASDAQ and NYSE.

The conditions of the strategy are as follows :

Entry : The MACD line is below the zero line and the color of the current histogram is green and the color of at-least previous 2 histograms is red.

Exit : Exit will be based on stop-loss of 1% and Target profit of 2%.

We are taking an entry when the stock has been in a downtrend and the MACD was diverging from the signal line but now started to converge indicating that the bearish momentum is slowing down.