What the MACD indicator is
MACD (Moving Average Convergence Divergence) is a trend-following momentum indicator created by Gerald Appel in the late 1970s. The MACD line is the difference between a 12-period and a 26-period exponential moving average (EMA) of the close. The signal line is a 9-period EMA of the MACD line, and the histogram is MACD minus the signal line.
How it is calculated
An EMA follows st = α·xt + (1 − α)·st−1, starting from the first observation (or an average of early values). For an N-period EMA the usual choice is α = 2 ÷ (N + 1), the relationship under which an exponential average and an N-point simple average behave similarly. This tool uses that convention.
Example: with the 40 sample closes loaded above (12, 26, 9, first close as seed), the latest MACD line is −0.7968, the signal line −1.1208 and the histogram 0.3240, so MACD is above its signal line.
Reading crossovers
- Signal-line crossover: MACD crossing above the signal line is a bullish signal; crossing below is bearish.
- Zero-line crossover: MACD moving from negative to positive is read as bullish, positive to negative as bearish.
- Histogram: it is positive when MACD is above the signal line. A shrinking histogram suggests momentum is fading.
Limits
MACD is built from past prices, so signals lag and can fail in sideways markets. The sample data above is made up. Paste your own closes, oldest first. This is not investment advice. Pair it with the RSI calculator or check results with stock gain/loss.
Frequently Asked Questions
How is MACD calculated?
MACD line = 12-period EMA minus 26-period EMA of closing prices. The signal line is a 9-period EMA of the MACD line, and the histogram is MACD minus signal.
What does a MACD crossover mean?
When the MACD line crosses above the signal line it is read as a bullish signal; crossing below is bearish. These are indicator readings, not guarantees.
How many prices do I need?
At least the slow period plus the signal period: 35 closes with the default 26 and 9. More data gives steadier values.
Can I change the 12, 26, 9 settings?
Yes. Enter any whole periods where the fast period is smaller than the slow one. 12/26/9 is the standard setting.
Is MACD the same as RSI?
No. MACD compares two moving averages of price; RSI measures the size of recent gains versus losses. They are often used together.