MACD Formula

Moving averages are used to identify trends by filtering out the erratic changes in a price chart. The MACD, a more advanced indicator, was created by Gerald Appel, and stands for Moving Average Convergence Divergence. People pronounce it Mac-D. It is made up of three exponential moving averages and appears on charts as two lines as shown in the MACD study below. The crossovers of the two moving averages give buy and sell signals. There is also something called the MACD Histogram we will cover in a later lesson.

The blue line in the study is called the Fast MACD. It is made up by first calculating a 12-day EMA of closing prices and a 26-day EMA of closing prices. The 26-day EMA is subtracted from the 12-day EMA and the result is plotted as a solid blue line and called the MACD fast line. Next a 9-day EMA of the MACD fast line is calculated and plotted as a red line. This is called the MACD slow signal.

 

 Trading Strategy

Moving averages represent an average consensus of values in a specific period of time, and in the case of stocks such moving averages represent a sort of composite snapshot of the mass feelings of the market. A short moving average measures short term consensus while a long moving average measures long term consensus. The crossovers of the MACD fast line and the MACD slow signal reveal shifts in the balance of power between the bulls and the bears. The fast line reflects a short consensus period while the slow line reflects a longer consensus period. Thus when the MACD fast line rises above the MACD slow signal, it indicates that the bulls are dominating the market and we may be trending up. In that case you want to trade from the long side. Conversely when the MACD fast line falls below the MACD slow signal, it indicates that bears are dominating the market, we might be trending down, and you can profit from the short side.

How can you use the MACD in your trading? You can set up a formula that compares the MACD fast line to the MACD slow signal so that when the fast line is greater than the slow, an alert is created and you can go long. To do this create a new formula like this:

MACD(Close,12,26,9,D) > MACDSig(Close,12,26,9,D)

You can name this Fast>Slow. When the formula becomes True it means that the fast signal has risen above the slow signal. (You can also set up an email alert using Tools-Plugins so that when the signals are given you will be sent an email. The program must be running for this to work). You can trade on the short side with the formula:

MACD(Close,12,26,9,D) < MACDSig(Close,12,26,9,D) 

This tells you the MACD may be trending down.

Traders often try to optimize the MACD by using a different moving average, for example 5-34-7 instead of 12-26-9. You can also try to link the MACD to market cycles, in which case the first EMA should be 1/4 the length of the dominant cycle, the second EMA would be tied to half the cycle length, and the third EMA can be arbitrary and not tied to a cycle. The only problem is if you tweak the MACD enough you can get it to give any signal you want.