MetaStock Moving Average Convergence Divergence (MACD) Function

Provided By

The MACD is a popular trend following momentum indicator that uses 26 period, 12 period and 9 period exponential moving averages in its calculation. Even though it is classed as a momentum indicator, the MACD also displays oscillator qualities (achieved by plotting the difference between two moving averages). These traits, and since its construction is quite simple, make it one of the most reliable indicators around. That said, as with all indicators, MACD is not infallible and should be used in conjunction with other technical analysis tools.


The primary MACD line plots the difference between a 26 period exponential moving average and a 12 period exponential moving average. Consequently the MACD oscillates around zero, without any upper or lower limits. Another line is added to the MACD for interpretation purposes and is called the signal or trigger line. The signal line is a 9 period exponential moving average of the MACD itself. Naturally, the signal line lags slightly behind the MACD.

There are 3 common methods to interpret the MACD:

1) Crossovers - When the MACD crosses above the slower trigger line, this is a bullish signal. Vice versa when the MACD falls below the signal line, it is a signal to sell.

2) Divergence - When the security diverges from the MACD it warns that the current trend may have come to an end.

3) Centreline Crossover - Some analysts choose to buy or sell when the MACD goes above or below zero (the centreline).


Metastock does not allow the user to alter the moving averages from 12 and 26 using the default MACD indicator. If you want to use different moving averages in the MACD, you will have to create your own MACD indicator using The Indicator Builder. Fortunately, in The Indicator Builder Chapter, we will show you how.

Also note that there is no MetaStock function that represents the signal line. If we wish to use the signal line, we can simply use the formula below to obtain a 9 period exponential moving average of the MACD.



The following formula searches for the MACD to be positive:



A more useful application of this example could be:

MACD()>Ref(MACD(),-1) AND MACD()>Mov(MACD(),9,E)

The formula above specifies that the present MACD value must be greater than the previous MACD value, i.e. a rising MACD (denoted by `MACD()>Ref(MACD(),-1)') and that the present MACD must be greater than the signal line (denoted by `MACD()>Mov(MACD(),9,E)').

Looking at Figure 3.25, we can see the MACD indicator and the signal line at the base of the chart.


Figure 3.25 _ MACD Indicator  


Construct formulas for the following:

1. The MACD is positive, however the previous MACD value was negative:


2. The MACD has crossed the signal line:


This article is a snippet from the
MetaStock Programming Study Guide...

"Discover The Simple Secret to Make Metastock Easy & Identify Profitable Trades"

Click Here To Find For More About
The MetaStock Programming Study Guide

copyright 2007