Moving Average Convergence Divergence (MACD)


The Moving Average Convergence Divergence (MACD), developed by Gerald Appel, is a widely used trend-following momentum indicator that shows the relationship between two Exponential Moving Averages (EMAs) of a security’s price. The MACD is composed of three main elements: the MACD line itself (the difference between two EMAs), a ‘signal line’ (an EMA of the MACD line), and a histogram (the difference between the MACD and signal lines). Traders use the MACD to identify changes in the direction, strength, and momentum of a price trend, often looking for crossovers between the MACD line and the signal line as potential buy or sell signals.

Function Syntax

=MACD(data,shortPeriod, longPeriod,signalPeriod  )  
  • data (array) :
    Range of columns containing the date, Open, high, Low, close, volume data.

  • shortPeriod (number):
    Number of periods (days) used for calculating the short-term Exponential Moving Average (EMA). Typically 12 periods.

  • longPeriod (number):
    Number of periods (days) used for calculating the long-term EMA. Typically 26 periods.

  • signalPeriod (number):
    Number of periods (days) used for calculating the EMA of the MACD line itself, known as the signal line. Typically 9 periods.

Returns:
A four-column array of dates with corresponding MACD line, signal line, and histogram values.

Output Example

Below is an example of the resulting array when applying the custom =MACD() function.

macd return array