How to calculate MACD
Charting packages routinely calculate MACD for you, but knowing how this indicator is created is important for gaining a better understanding of how it works. The MACD calculation isn’t complex; it’s just three exponential moving averages. Here are the steps:-
Calculate a 12-period EMA.
-
Calculate a 26-period EMA.
-
Subtract the 26-period EMA from the 12-period EMA to create the MACD line.
-
Use the resulting MACD line to calculate a 9-period EMA to create the signal line.
-
Plot the MACD as a solid line; plot the signal line as either a dashed or lighter-colored line.
Consider this weekly chart of AGCO Corp. (AG) along with an MACD indicator and an MACD histogram. The indicator was originally designed to be used as a weekly chart, and a weekly MACD indicator provides more useful information about the strength and direction of a trend and potential trend reversals. You will find that other traders use this indicator for both longer and shorter periods as well.
You may also notice that the MACD line crossed the signal line in early January 2006. This MACD crossover signal is another early indication suggesting a possible new uptrend.
You can automatically generate an MACD indicator at StockCharts.com as well. Use the dropdown menu in the Indicators section of Chart Attributes to find MACD. Then set the parameters and position it above or below the chart. The parameters for the MACD line suggested above would be 12, 26, 9. You should also select the MACD Histogram with the same parameters.
How to use MACD
MACD provides a remarkable amount of information in a concise format. MACD oscillates above and below a center zero line and is a good indicator for showing the direction of the dominant trend, signaling-
An uptrend when the MACD line crosses above the center line
-
A downtrend when the MACD line crosses below the center line
-
Buy signals when the MACD line crosses above the signal line
-
Sell signals when the MACD line crosses below the signal line
The weekly prices for the S&P 500 Depository Receipts is sometimes called SPDRs or Spyders. (The stock symbol is SPY.) SPY is an exchange-traded fund that tracks the S&P 500 index.
In a bearish divergence, the stock establishes a series of higher lows and higher highs, while the MACD establishes a series of lower highs. A bullish divergence is the reverse: The stock establishes a series of lower lows and lower highs, while the MACD establishes a series of higher highs.
Divergences that occur in the same direction as the dominant trend are often useful for entering positions. However, a divergence that is counter to the dominant trend is less likely to be a reliable trading signal.
This bearish divergence on SPY is best interpreted as a signal showing that the momentum of the multiyear S&P 500 bull market was slowing. In fact, the market peaked in October 2007 and remained in a downtrend for many months.Each time the MACD line crosses above or below the signal line suggests a potential change in the direction of the dominant trend. Although it’s not an outright buy signal or sell signal, it does suggest that a change may be in the wind.
In the case of a bearish divergence, the best way to exploit that information is to monitor individual stocks and ETFs for weakness and either close long positions when they deteriorate or initiate new short positions as they present themselves.
Most charting packages enable you to fine-tune the MACD calculation. Many traders vary the 12-, 26-, and 9-week values. Although nothing is inherently wrong with this approach, you nevertheless risk the curve-fitting problem whenever you try to find parameters that give you better results for a specific stock.
That said, Gerald Appel, the man who developed MACD, uses values different from the original 12, 26, and 9. He also uses different values to generate buy signals than he does to generate sell signals. So feel free to experiment and have fun after you gain some experience with the default parameters.