MACD Indicator Explained - What Does Everything Mean?

Take a look under the hood of the MACD indicator, and understand the formulas and calculations that power the different MACD lines and histogram

youtube-video-thumbnail
MACD Crossover Scan

If you'd like to scan for MACD crossing over the zero line, you can use our free MACD Crossover Scans, and start tweaking the scans to work for you.

Introduction

The MACD is one of the most widely used trading indicators out there, and for good reason.

But there are still a lot of traders that don’t really understand how it works.

In this video, we’ll dive into the different components of the MACD, and see what all goes on behind the scenes.

MACD Divergence on S&P 500

We’ll break down the MACD trading indicator, and take a look under the hood to see all of the different components that make up the indicator.

We’ll discuss

  • What all of the different lines on the MACD really mean?
  • What is going on behind the scenes in the indicator?
  • How are the formulas calculated?
  • What are the different levers we can tweak and adjust?

By the end of this video, you should have a much better understanding of what’s going on behind the scenes in the indicator, and what all of these different lines mean.

We can then apply that knowledge to charting, backtesting, and developing our own trading indicators.

*Note: We are using the MACD Indicator for the ThinkOrSwim platform in this tutorial.

 

How to Use MACD

Let’s start by talking about how most people traditionally use the MACD indicator.

Most people use the MACD to help identify potential turning points in the market.

The indicator is calculated using two moving averages, and the distance between those moving averages is plotted on the chart.

When the distance between the two moving averages starts to widen, that is often indicative of increasing momentum in the market, and vice versa.

When the distance starts to narrow, that often indicates slowing momentum, and the potential for a reversal.

The traditional way to trade the MACD is to look for divergences between price and the indicator.

  • A bullish divergence occurs when price makes a new low, but the MACD doesn’t.
  • A bearish divergence occurs when price makes a new high, but the MACD doesn’t.

Divergences like these can often be leading indicators of a potential trend reversal.

Bullish Divergence:

A bullish divergence occurs when price action makes a lower low, but the MACD line makes a higher low.

MACD Bullish Divergence Example

This is an indication that momentum is starting to shift to the upside, and a bullish reversal may be forthcoming.

 

Bearish Divergence:

A bearish divergence occurs when price action makes a higher high, but the MACD line makes a lower high.

MACD Bearish Divergence Example

This is an indication that momentum is starting to shift to downside, and a bearish reversal may be forthcoming.

Let’s move on next to opening up the code, so we can study each one of these different components and see how they are calculated.

 

MACD Value Line

The MACD is made up of two different moving averages, which are lagged behind price action.

The default settings on most platforms is to use a 12-period moving average, and a 26-period moving average.

MACD Indicator Settings

These two averages are lagged behind price action, which means they are always a few periods behind where price is currently trading.

The difference between these two moving averages is then plotted on the chart as a line.

Inside of ThinkOrSwim, this line is known as the Value line.

MACD Indicator Value Line

Other platforms may refer to this as the MACD line; the terms are interchangeable.

The MACD Value line is calculated by using two moving averages.

On a high level, and in English, the formula reads something like this:

MACD Value Line = EMA1 - EMA2
  • The most commonly used value for EMA1 is the 12-period EMA.
  • The most commonly used value for EMA2 is the 26-period EMA.

EMA2 is subtracted from EMA1, and the resulting value gives us the the Value Line.

Inside of ThinkOrSwim's MACD indicator, you'll find the following as the calculation used:

input fastLength = 12;
input slowLength = 26;
input averageType = AverageType.EXPONENTIAL;
plot Value = MovingAverage(averageType, close, fastLength) - MovingAverage(averageType, close, slowLength);

In laymen’s terms, the MACD value line gives us insight into the distance between the 12 EMA and 26 EMA, to gauge a sense of trend and momentum.

 

MACD Avg Line

In addition to the Value line, there’s also a 9-period moving average of the Value line, which is plotted as a separate line.

MACD Indicator Signal Line

Inside of ThinkOrSwim, this line is known as the Avg line.

Other platforms may refer to this as the “signal line”; the terms are interchangeable.

The MACD Avg line is the 9-period moving average of the Value line.

This 9-period moving average is lagged behind the Value line, which makes it a good leading indicator for spotting potential reversals.

The formula to calculate the MACD Signal Line inside of ThinkOrSwim is this:

input MACDLength = 9;
plot Avg = MovingAverage(averageType, Value, MACDLength);

There are many traders who look at a crossover in the MACD Value or Average near the zero line to be a key indication of a change in trend direction.

 

MACD Histogram

The MACD histogram is simply the difference between the Value line and the Avg line.

MACD Indicator Histogram

The formula for it inside of ThinkOrSwim is:

plot Diff = Value - Avg;

The MACD histogram is what we often see people refer to as “the MACD,” but the histogram is actually just one component of the overall indicator.

However, ThinkOrSwim uses the histograms as a means of determining the up and down signal, that comes built inside of the indicator.

 

Summary

At the end of the day, the MACD is just a difference between two moving averages, outputted 3 different ways.

  • Value line = calculated by taking the 12-period EMA, and subtracting the 26-period EMA from it.
  • Avg line = 9-period moving average of the Value line.
  • Histogram = simply the difference between the Value line and the Avg line.

The traditional way to use the MACD is to look for divergences between price and the MACD line, as a leading indicator of potential reversals. Which really implies, that you’re looking for a divergence using the slope of two moving averages.

MACD Indicator for ThinkOrSwim

There are also many different ways to customize the MACD indicator.

The most common way people do this is by adjusting the time period of the moving averages that are used to calculate the indicator.

  • A shorter time period will make the indicator more sensitive, resulting in more signals, but potentially more whipsaw as well.
  • A longer time period will make the indicator feel less responsive, resulting in fewer signals, but also potentially giving you

Of course, divergences are not the only way to trade the MACD. There are many different ways to trade this indicator.

I encourage you to open up the code and study it more for yourself.

We hope you enjoyed this tutorial and found the information useful. Especially for those of you looking to make sense of the ThinkOrSwim naming conventions.

Take care everyone, and good luck trading!

Table of Contents
    Add a header to begin generating the table of contents

    Trade Like a Pro, With the Pros