Function File: [macdvec, nineperma] = macd (data)
Function File: [macdvec, nineperma] = macd (data, dim)

Calculate the Moving Average Convergence/Divergence (MACD) line of an asset from the vector of prices (data). Also calculate the nine-period exponential moving average from the MACD line. If given, dim indicates whether each row is a set of observations (dim = 2) or each column is a set of observations (dim = 1, the default).

The MACD line is calculated as the twelve-period exponential moving average (EMA) minus the 26-period EMA. Closing prices are typically used for the moving averages. The nine-period EMA of the MACD line is used as the signal line.

Package: financial