Calculate MACD from closing prices or from known fast and slow EMAs, with the signal line and histogram for standard 12/26/9 or custom periods.
MACD Formula
The following formula is used to calculate the moving average convergence divergence.
- Where MACD is the moving average convergence divergence
- 12EMA is the 12-period exponential moving average
- 26EMA is the 26-period exponential moving average
To calculate the standard moving average convergence divergence (MACD), subtract the 26-period exponential moving average from the 12-period exponential moving average. The standard signal line is a 9-period EMA of MACD, and the histogram is MACD minus the signal line.
MACD Definition
What is MACD?
MACD, short for moving average convergence divergence, is a metric or indicator used in finance that shows the relationship between the moving averages of a security. The MACD is considered a trend-following momentum indicator.
The standard moving averages are the 12-period and 26-period exponential averages; other periods can be selected. From Prices uses oldest-to-newest closing prices at equal intervals and initializes each EMA with a simple average. Earlier history or another initialization method can produce different chart values.
Example Problem
How to calculate MACD?
First, determine the 12-period moving average. For this example, the exponential 12-period value is found to be $5.50.
Next, determine the 26-period moving average. For this example, this moving average is found to be $3.50.
Finally, calculate the MACD using the formula above:
MACD = 12 EMA - 26 EMA
MACD = $5.50 - $3.50
MACD = $2.00
