||This article includes a list of references, but its sources remain unclear because it has insufficient inline citations. (December 2012)|
MACD (moving average convergence/divergence) is a technical analysis indicator created by Gerald Appel in the late 1970s. It is used to spot changes in the strength, direction, momentum, and duration of a trend in a stock's price.
The MACD "oscillator" or "indicator" is a collection of three signals (or computed data-series), calculated from historical price data, most often the closing price. These three signal lines are: the MACD line, the signal line (or average line), and the difference (or divergence). The term "MACD" may be used to refer to the indicator as a whole, or specifically to the MACD line itself. The first line, called the "MACD line", equals the difference between a "fast" (short period) exponential moving average (EMA), and a "slow" (longer period) EMA. The MACD line is charted over time, along with an EMA of the MACD line, termed the "signal line" or "average line". The difference (or divergence) between the MACD line and the signal line is shown as a bar graph called the "histogram" time series (which should not be confused with the normal usage of histogram as an approximation of a probability distribution in statistics - the commonality is just in the visualization using a bar graph).
A fast EMA responds more quickly than a slow EMA to recent changes in a stock's price. By comparing EMAs of different periods, the MACD line can indicate changes in the trend of a stock. By comparing that difference to an average, an analyst can detect subtle shifts in the stock's trend.
Since the MACD is based on moving averages, it is inherently a lagging indicator. However, in this regard the MACD does not lag as much as a basic moving average crossing indicator, since the signal cross can be anticipated by noting the convergence far in advance of the actual crossing. As a metric of price trends, the MACD is less useful for stocks that are not trending (trading in a range) or are trading with erratic price action.
The MACD was invented by Gerald Appel in the 1970s. Thomas Aspray added a histogram to the MACD in 1986, as a means to anticipate MACD crossovers, an indicator of important moves in the underlying security.
Appel has authored numerous publications on investment strategies including, Stock Market Trading Systems, The Big Move and Winning Market Systems.
Basic components 
The graph above shows a stock with a MACD indicator underneath it. The indicator shows a blue line, a red line, and a histogram or bar chart which calculates the difference between the two lines. Values are calculated from the price of the stock in the main part of the graph.
For the example above this means:
- MACD line (blue line): difference between the 12 and 26 days EMAs
- signal (red line): 9 day EMA of the blue line
- histogram (bar graph): difference between the blue and red lines
- MACD = EMA[stockPrices,12] – EMA[stockPrices,26]
- signal = EMA[MACD,9]
- histogram = MACD – signal
The period for the moving averages on which an MACD is based can vary, but the most commonly used parameters involve a faster EMA of 12 days, a slower EMA of 26 days, and the signal line as a 9 day EMA of the difference between the two. It is written in the form, MACD (faster, slower, signal) or in this case, MACD(12,26,9).
Exponential moving averages highlight recent changes in a stock's price. By comparing EMAs of different lengths, the MACD line gauges changes in the trend of a stock. By then comparing differences in the change of that line to an average, an analyst can identify subtle shifts in the strength and direction of a stock's trend.
Traders recognize three meaningful signals generated by the MACD indicator.
- the MACD line crosses the signal line
- the MACD line crosses zero
- there is a divergence between the MACD line and the price of the stock or between the histogram and the price of the stock
Graphically this corresponds to:
- the blue line crossing the red line
- the blue line crossing the x-axis (the straight black line in the middle of the indicator)
- higher highs (lower lows) on the price graph but not on the blue line, or higher highs (lower lows) on the price graph but not on the bar graph
- MACD – signal = 0
- EMA[fast,12] – EMA[slow,26] = 0
- Sign (relative price extremumfinal – relative price extremuminitial) ≠ Sign (relative MACD extremumfinal – MACD extremuminitial)
Signal–line crossover 
Signal–line crossovers are the primary cues provided by the MACD. The standard interpretation is to buy when the MACD line crosses up through the signal line, or sell when it crosses down through the signal line.
The upwards move is called a bullish crossover and the downwards move a bearish crossover. Respectively, they indicate that the trend in the stock is about to accelerate in the direction of the crossover.
The histogram shows when a crossing occurs. Since the histogram is the difference between the MACD line and the signal line, when they cross there is no difference between them.
The histogram can also help in visualizing when the two lines are approaching a crossover. Though it may show a difference, the changing size of the difference can indicate the acceleration of a trend. A narrowing histogram suggests a crossover may be approaching, and a widening histogram suggests that an ongoing trend is likely to get even stronger.
While it is theoretically possible for a trend to increase indefinitely, under normal circumstances, even stocks moving drastically will eventually slow down, lest they go up to infinity or down to nothing.
Zero crossover 
A crossing of the MACD line through zero happens when there is no difference between the fast and slow EMAs. A move from positive to negative is bearish and from negative to positive, bullish. Zero crossovers provide evidence of a change in the direction of a trend but less confirmation of its momentum than a signal line crossover.
The MACD is only as useful as the context in which it is applied. An analyst might apply the MACD to a weekly scale before looking at a daily scale, in order to avoid making short term trades against the direction of the intermediate trend. Analysts will also vary the parameters of the MACD to track trends of varying duration. One popular short-term set-up, for example, is the (5,35,5).
False signals 
Like any forecasting algorithm, the MACD can generate false signals. A false positive, for example, would be a bullish crossover followed by a sudden decline in a stock. A false negative would be a situation where there was no bullish crossover, yet the stock accelerated suddenly upwards.
A prudent strategy would be to apply a filter to signal line crossovers to ensure that they will hold. An example of a price filter would be to buy if the MACD line breaks above the signal line and then remains above it for three days. As with any filtering strategy, this reduces the probability of false signals but increases the frequency of missed profit.
Analysts use a variety of approaches to filter out false signals and confirm true ones.
Oscillator classification 
The MACD is an absolute price oscillator (APO), because it deals with the actual prices of moving averages rather than percentage changes. A percentage price oscillator (PPO), on the other hand, computes the difference between two moving averages of price divided by the longer moving average value.
While an APO will show greater levels for higher priced securities and smaller levels for lower priced securities, a PPO calculates changes relative to price. Subsequently, a PPO is preferred when: comparing oscillator values between different securities, especially those with substantially different prices; or comparing oscillator values for the same security at significantly different times, especially a security whose value has changed greatly.
A third member of the price oscillator family is the detrended price oscillator (DPO), which ignores long term trends while emphasizing short term patterns.
Signal processing theory 
In signal processing terms, the MACD is a filtered measure of the derivative of the input (price) with respect to time. (The derivative is called "velocity" in technical stock analysis). MACD estimates the derivative as if it were calculated and then filtered by the two low-pass filters in series, multiplied by a "gain" equal to the difference in their time constants. It also can be seen to approximate the derivative as if it were calculated and then filtered by a single low pass exponential filter (EMA) with time constant equal to the sum of time constants of the two filters, multiplied by the same gain. So, for the standard MACD filter time constants of 12 and 26 days, the MACD derivative estimate is filtered approximately by the equivalent of a low-pass EMA filter of 38 days. The time derivative estimate (per day) is the MACD value divided by 14.
The signal line is also a derivative estimate, with an additional low-pass filter in series for further smoothing (and additional lag). The difference between the MACD line and the signal (the "histogram") represents a measure of the second derivative of price with respect to time ("acceleration" in technical stock analysis). This estimate has the additional lag of the signal filter and an additional gain factor equal to the signal filter constant.
A MACD crossover of the signal line indicates that the direction of the acceleration is changing. The MACD line crossing zero suggests that the average velocity is changing direction.
Further reading 
See also 
- Appel, Gerald (1999). Technical Analysis Power Tools for Active Investors. Financial Times Prentice Hall. p. 166. ISBN 0-13-147902-4.
- INO TV - Author: Gerald Appel
- Murphy, John (1999). Technical Analysis of the Financial Markets. Prentice Hall Press. pp. 252–255. ISBN 0-7352-0066-1.
- The MACD Approach to Derivative (Rate of Change) Estimation