MACD & MACD Histogram

Gerald Appel created MACD for the purpose of producing specific trading signals. The primary reason for its popularity among technicians is the fact that it is a very easy indicator to interpret. Price moving averages help us to identify trends more effectively by smoothing out daily price fluctuations. Most of us are familiar with using crossovers of simple price moving averages to arrive at buy and sell signals (i.e. when price crosses up through its moving average a bullish condition exists). MACD is a very similar concept. However, MACD consists of three price moving averages, instead of just one or two Price Moving Average's.

MACD is displayed as two separate lines in the indicator window. The first line plotted is actually the difference between two moving averages. The first MA should be set to a shorter term time frame (e.g. 12-day) and the second MA is typically set to a number about twice as long as the first. These parameters are determined by the user, based on his or her particular time horizons.

The calculation of the second indicator line is simply an average of the first line. A common parameter used here is a 9-day moving average, but we encourage you to experiment with varying parameters since NO indicator parameter works best for all market conditions.

The histogram is the difference between the two MACD lines. Where the histogram crosses the zero line is the point where the two MACD lines are crossing (the difference between the two is zero).

In the chart below we have MACD and a MACD histogram plotted in the same pane so you can see the histogram crossing up and down through 0 when MACD crossing up or down through its moving average.

Custom PCF Formula
Exponential of Price MACD MACDs.l.z
s=Short, l=Long, x=Trigger, z=Offset
Trigger or Signal XAVG(MACDs.l.z, x)
Histogram MACDs.l.z - XAVG(MACDs.l.z, x)
Generalized MACD tAVG(w, s) - tAVG(w, l)
t=AverageType,
w=Numeric, s=Short, l=Long, x=Trigger
Trigger or Signal tAVG(tAVG(w, s) - tAVG(w, l), x)
Histogram tAVG(w, s) - tAVG(w, l) - tAVG(tAVG(w, s) - tAVG(w, l), x)

Where s is the short period which must be an integer.

Where l is the long period which must be an integer.

Where x is the trigger period which must be an integer.

Where z is the offset. An offset of 1 returns the value from 1 bar ago.

Where t is the Average Type (most MACDs are exponential). Leave blank for Simple, X for Exponential, F for Front Weighted, and H for Hull.

Where w is any formula returning a numeric value.

Examples

An exponential MACD 12, 26 can be written as follows.

MACD12.26

An exponential MACD trigger 12,26,9 can be written as follows.

XAVG(MACD12.26, 9)

An exponential MACD Histogram 12,26,9 is the difference between the MACD and its trigger and can be written as follows.

MACD12.26 - XAVG(MACD12.26, 9)

Read more about MACD/MACD Histogram at Investopedia