Financial Time Series Toolbox | ![]() ![]() |
Moving Average Convergence/Divergence (MACD)
Moving Average Convergence/Divergence (MACD) is an oscillator function used by technical analysts to spot overbought and oversold conditions. Look at the portion of the time series covering the three-month period between October 1, 1995 to December 31, 1995. At the same time fill any missing values due to holidays within the time period specified:
Now calculate the MACD, which when plotted produces two lines; the first line is the MACD line itself and the second is the nine-period moving average line:
Note
When you call macd without giving it a second input argument to specify a particular data series name, it searches for a closing price series named Close (in all combinations of letter cases). For more detail on the macd function, see macd in the Function Reference. |
Plot the MACD lines and the High-Low plot of the IBM stock prices in two separate plots in one window.
subplot(2, 1, 1); plot(macd_ibm); title('MACD of IBM Close Stock Prices, 10/01/95-12/31/95'); datetick('x', 'mm/dd/yy'); subplot(2, 1, 2); highlow(part_ibm); title('IBM Stock Prices, 10/01/95-12/31/95'); datetick('x', 'mm/dd/yy')
Figure 3-1, MACD and IBM Stock Prices shows the result.
Figure 3-1: MACD and IBM Stock Prices
![]() | Examples | William's %R | ![]() |