Sunday, July 22, 2007

Moving Average Convergence/Divergence (MACD)

Moving Average Convergence/Divergence (MACD)

Introduction
Developed by Gerald Appel, Moving Average Convergence/Divergence (MACD) is one of the simplest and most reliable indicators available. MACD uses moving averages, which are lagging indicators, to include some trend-following characteristics.

These lagging indicators are turned into a momentum oscillator by subtracting the longer moving average from the shorter moving average. The resulting plot forms a line that oscillates above and below zero, without any upper or lower limits.

MACD Formula
The most popular formula for the MACD is the difference between a security's 26-day and 12-day Exponential Moving Averages(EMAs).

Of the two moving averages that make up MACD, the 12-day EMA is the faster and the 26-day EMA is the slower. Closing prices are used to form the moving averages. Usually, a 9-day EMA of MACD is plotted along side to act as a trigger line. A bullish crossover occurs when MACD moves above its 9-day EMA, and a bearish crossover occurs when MACD moves below its 9-day EMA.

The histogram is positive when MACD is above its 9-day EMA and negative when MACD is below its 9-day EMA.

Interpretation
MACD is a trend following indicator, and is designed to identify trend changes. It's generally not recommended for use in ranging market conditions. Three types of trading signals are generated,
* MACD line crossing the signal line.
* MACD line crossing zero
* Divergence between price and MACD levels

The signal line crossing is the usual trading rule. This is to buy when the MACD crosses up through the signal line, or sell when it crosses down through the signal line.

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.

A crossing of the MACD line up through zero is interpreted as bullish, or down through zero as bearish.

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 bullish, suggesting the downtrend may be nearly over.

Negative divergence is when price makes a new rally high, but MACD doesn't rise as high as before, this is bearish.

Trading Signals
First check whether price is trending. If MACD is flat or stays close to the zero line, the market is ranging and signals are unreliable.
Go long when the MACD line crosses the signal line from below.
Go short when the MACD line crosses the signal line from above.

Signals are far stronger if there is either:
a divergence on the MACD line; or
a large swing above or below the zero line.

To Calculate Moving Average CD of Nifty or Individual stock in MS Excel:.

Column, values to enter, formulas you have to enter

A = Company Name/date
B = Open
C = High
D = Low
E = LTP/close
F = Volumes

G (12DAY EMA)= first we have to calculate 12-Day Ema
for 12 day ema,we have to calculate 11-day Simple mov.aver(SMA).Formula= =Sum(E2:E12)/11,enter formula in G12
in 13 row of G column we have to calulate ema

EMA formula = price today * k + EMA yesterday's * (1-k) where N is number of days in your ema

OR X(EMA) = (K x (C - P)) + P

X = Current EMA,C = Current Price,P = Previous period's EMA*,K = Smoothing constant
(*A SMA is used for first period's calculation),K = 2/(1+N),N = Number of periods for EMA

calculation
K = 2/(1+N)
12day=2/(12+1)=0.15
26day=2/(26+1)=0.074

so formula for 12day ema would be =E13*0.15+G12*(1-0.15) OR (0.15*(E12-G12))+G12,enter formula in G13,copy the formula till latest closing price.

H (26DAY EMA)= now we have to calculate 26 day ema,so u have to go thru the mov.aver.for. steps once again
we have to calculate 25-day Simple mov.aver(SMA).Formula= =Sum(E2:E26)/25 enter formula in G26

so formula for 26day ema would be =E27*0.074+H26*(1-0.074) OR (0.074*(E27-H27))+H27,enter formula in H27,copy the formula till latest closing price.

I (MACD[FAST LINE])= Subtract 26-day ema from 12-day ema.so formula =H27-G27, enter in I27,copy the formula till latest closingprice.

J (9-day ema[Slow Line]) = first we have to calculate 9-Day Ema of MACD(trigger/signal line)
calculate 8-day Simple mov.aver(SMA).Formula =SUM(I27:I34)/8,enter the formula in J34
then,Ema kicks in
K = 2/(1+N), so 2/(9+1)=0.2
=I35*0.2+J34*(1-0.2),enter the formula in J35,copy the formula till latest closing price.

K (MACD Histogram)= we have subtract Slow line(J34)from Fast line(I34) so formula =J34-I34,enter in K34,copy the formula till latest closing price.






Kindly recommend my blog to your friends,if it is useful to u,by telling them and giving backlink in your blog.thanks in advance.

5 comments :

Anonymous said...

Hi
Thankyou for your good work.But request you to request the Formulas u have given again.Excel doesn't allow to enter the formula in the same cell whose reference is used.

Check the column in which u have written to enter 13 day EMA formula.

You can contact me at akhil20@gmail.com
Regards
Akhil Goel

niftyxl said...

hi akhil,
i am so sorry.thanx for pointing the mistake,it was by mistake,i wrote G12 intead of G13.

now i have corrected it.thanx once again.

if any more such mistakes are there, pls bring to my notice...

regards.

Unknown said...

hi
thankx for providin us wid this information but do you any sight which gives chart about macd for stocks....!
thanks
krishnendu gupta

Grand Cru said...

Hi GJ, may I query your MACD calculation ... you give it as "(MACD[FAST LINE])= Subtract 26-day ema from 12-day ema. so formula =H27-G27" ... but H27-G27 is EMA26 - EMA12! so is the formula the wrong way round or the text? Thanks for your website, very helpful.

DC

Grand Cru said...

Sorry GJ but you've done it again with ... "(MACD Histogram)= we have subtract Slow line(J34)from Fast line(I34) so formula =J34-I34) ... no, formula would be I34-J34 or text is wrong way round.

Popular Posts for last 7 days

All Time Popular Posts