Banking, Finance and Investment Industry
VBA / Software Developer: Francis Lim
Project Categories: Data-Mining, Data Cleansing, Financial Modelling, Numerical Analysis
Freeware: MACD Historical Stock Data
System Requirements
Windows XP, Windows Vista, Windows 7
Microsoft Excel 2003 or above
This Excel Spreadsheet downloads historical stock prices provided by Yahoo Finance. A freeware Spreadsheet. It is written in Visual Basic Applications (VBA), a macro programming language for Microsoft Office - Access, Excel, Word, FrontPage, Outlook, PowerPoint, and Visio.
To know your stock ticker quotes, please refer to yahoo.finance.com. The downloaded stock data contains Date and Close in ascending date order.
How to Use MACD Excel Sheet
You will need to enable macros for this spreadsheet to work. To enable macros, go to Excel Menu - Tools / Options, click on the Security tab and go to Macro Security. Change the setting to Medium, close and reopen the workbook It will ask you if you want to enable Macros, click 'Yes' to enable it.
User can input the following cells in the MACD Excel Sheet:-
B1 Cell Row - Yahoo Ticker
Enter a valid stock ticker code. If you're not sure of the stock symbol, click on 'Yahoo Symbol Lookup' to Yahoo Finance website.
B2 Cell Row - EMA (Fast)
Input the Exponential Moving Average (Fast), default is value 12.
B3 Cell Row - EMA (Slow)
Input the Exponential Moving Average (Slow), default is value 29.
B4 Cell Row - Signal Line
Input the Signal line of MACD, default is value 9.
B5 Cell Row - Start Date
The start date for the historical data.
Just Press "Retrieve Data" Button, it will download Historical Data from Yahoo Finance website run the MACD calculation and chart.
What is MACD?
MACD, which stands for Moving Average Convergence / Divergence, is a technical analysis indicator created by Gerald Appel in the late 1970s.
MACD shows the difference between a fast and slow exponential moving average (EMA) of closing prices. Since it is based on moving averages, MACD is inherently a lagging indicator.
MACD is a form of Absolute Price Oscillator (APO), mean ing that it takes the difference of two price EMAs. An alternate form of price oscillator is the Percentage Price Oscillator (PPO) which is computed by dividing the difference between two moving averages of price by the longer moving average value. The relative values generated by a PPO will differ from an APO (or MACD) in subtle but significant ways, and are preferred when (a) comparing the oscillator values between different securities, especially of widely different prices, or (b) comparing oscillator values for the same security at significantly different times, especially for a security whose value has changed greatly. The APO (and hence the MACD) will show greater oscillator extremes for higher priced securities, unlike the percentage price oscillator.
Thomas Aspray added a histogram to the MACD indicator in 1986, as a means to anticipate MACD crossovers, and thereby not miss important moves in a security.
The example graph above right shows the MACD line, its signal line, and its histogram. The upper graph is the prices. The lower graph has the MACD line in blue. The signal line, which is another EMA of the MACD values themselves, is in red. The difference between the MACD line and its signal line is plotted histogram style along with the two MACD lines.
The set of periods for the averages can be varied. Appel and others have experimented with different combinations. The usual set of parameters is written as 12,26,9 for the fast EMA, slow EMA and signal line periods respectively.
The standard periods originally published by Gerald Appel are 12 and 26 days:
A signal line (or trigger line) is then formed by smoothing this with a further EMA. The standard period for this is 9 days,
MACD lines are often regarded as a trend following indicator designed to identify trend changes. The MACD histogram as drawn above is sometimes used as an oscillator. Three types of trading signals are generated:
MACD line crossing the signal line.
MACD line crossing 0.
Divergence between price and histogram, or between MACD line and price.
The signal line crossing is the usual trading rule. The standard interpretation is to buy when the MACD crosses up through the signal line, or sell when it crosses down through the signal line. These crossings may occur too frequently, and other tests may have to be applied.
The histogram shows when a crossing occurs. When the MACD line crosses through zero on the histogram it is said that the MACD line has crossed the signal line. The histogram can also help visualizing when the two lines are coming together. Both may still be rising, but coming together, so a falling histogram suggests a crossover may be approaching.
A crossing of the MACD line up through zero is interpreted as bullish, or down through zero as bearish. These crossings are of course simply the original EMA(12) line crossing up or down through the slower EMA(26) line.
Positive divergence between MACD and price arises when price makes a new selloff low, but the MACD doesn't make a new low (i.e. it remains above where it fell to on that previous price low). This is interpreted as bullish, suggesting the downtrend may be nearly over. Negative divergence is the same thing when rising (i.e. price makes a new rally high, but MACD doesn't rise as high as before), this is interpreted as bearish.
Divergence may be similarly interpreted on the price versus the histogram, where the new price levels are not confirmed by new histogram levels. Longer and sharper divergences (distinct peaks or troughs) are regarded as more significant than small shallow patterns in this case.
It is recommended to look at a MACD on a weekly scale before looking at a daily scale to avoid making short term trades against the direction of the intermediate trend.
Sometimes it is prudent to apply a price filter to the Bullish Moving Average Crossover to ensure that it will hold. An example of a price filter would be to buy if MACD breaks above the 9-day EMA and remains above for three days. The buy signal would then commence at the end of the third day.
The MACD is a filtered measure of the velocity. The velocity has been passed through two first order linear low pass filters. The "signal line" is that resulting velocity, filtered again. The difference between those two, the histogram, is a measure of the acceleration, with all three filters applied. The "MACD crossing the signal line" suggests that the direction of the acceleration is changing. "MACD line crossing zero" suggests that the average velocity is changing direction.