Moving Average Convergence/Divergence (MACD)
fts2timetable to convert a
fints object to a
[MACDLine,SignalLine] = macd(Data)
Load the file
SimulatedStock.mat, which provides a timetable (
TMW) for financial data for TMW stock.
load SimulatedStock.mat [MACDLine, signalLine]= macd(TMW); plot(MACDLine.Time,MACDLine.Close,signalLine.Time,signalLine.Close); legend('MACDLine','NinePerMA') title('MACD for TMW')
Data— Data with high, low, open, close information
Data with high, low, open, close information, specified as a matrix,
table, or timetable. For matrix input,
Data is an
4 matrix of high, low,
opening, and closing prices. Timetables and tables with
rows must contain variables named
'Close' (case insensitive).
MACDLine— MACD series
MACD series, returned with the same number of rows (
and type (matrix, table, or timetable) as the input
calculated by subtracting the 26-period (7.5%) exponential.
SignalLine— Nine-period exponential series
Nine-period exponential series, returned with the same number of rows
M) and type (matrix, table, or timetable) as the
Data. The nine-period (20%) exponential moving
average of the
MACDLine is used as the
The MACD is calculated by subtracting the 26-period (7.5%) exponential moving average from the 12-period (15%) moving average.
The nine-period (20%) exponential moving average of the MACD line is used as the "signal" line. When the two lines are plotted, they can give you indications on when to buy or sell a stock, when overbought or oversold is occurring, and when the end of trend may occur. For example, when the MACD and the 20-day moving average line have crossed and the MACD line becomes below the other line, it is time to sell.
 Achelis, S. B. Technical Analysis from A to Z. Second Edition. McGraw-Hill, 1995, pp. 166–168.