Monday, November 26, 2007

Average Directional Index (ADX):Meaning & Calculation

J. Welles Wilder developed the Average Directional Index (ADX) to evaluate the strength of a current trend, be it up or down.

It's important to determine whether the market is trending or trading (moving sideways), because certain indicators give more useful results depending on the market doing one or the other.

The ADX is an oscillator that fluctuates between 0 and 100. Even though the scale is from 0 to 100, readings above 60 are relatively rare. Low readings, below 20, indicate a weak trend and high readings, above 40, indicate a strong trend.

The indicator does not grade the trend as bullish or bearish, but merely assesses the strength of the current trend. A reading above 40 can indicate a strong downtrend as well as a strong uptrend.

ADX can also be used to identify potential changes in a market from trending to non-trending. When ADX begins to strengthen from below 20 and moves above 20, it is a sign that the trading range is ending and a trend is developing.

When ADX begins to weaken from above 40 and moves below 40, it is a sign that the current trend is losing strength and a trading range could develop.

Positive/Negative Directional Indicators
The ADX is derived from two other indicators, also developed by Wilder, called the Positive Directional Indicator (sometimes written +DI) and the Negative Directional Indicator (-DI).

In its most basic form, buy and sell signals can be generated by +DI/-DI crosses.

A buy signal occurs when +DI moves above -DI and a sell signal when -DI moves above the +DI.
As with most technical indicators, +DI/-DI crosses should be used in conjunction with other aspects of technical analysis.

The ADX combines +DI with -DI, and then smooths the data with a moving average to provide a measurement of trend strength. Because it uses both +DI and -DI, ADX does not offer any indication of trend direction, just strength.

The Directional Movement Index, DMI, is an effective and frequently used trend indicator. This system was designed by Welles Wilder Jr. and is made up of three lines:
1. The +DI indicates the up average.
2. The -DI indicates the down average.
3. The ADX, average directional movement index, shows whether a trend is in effect by smoothing the difference between the +DI and -DI.

The time periods most commonly used in the complex formula are 10 or 14 days.

According to Wilder the DMI should be used with the ADX as a filter.
A rising ADX line means the market is trending and a better candidate for a trend-following system.

A falling ADX line indicates a non-trending market.

Some traders also look for an ADX greater than 20 or 25 to confirm that the market is trending. When the ADX line starts to drop from above the 40 level, that is an early sign that the trend is weakening. A rise back above 20 is often a sign of the start of a new trend.

Generally speaking, the two main buy and sell signals generated by DMI are as follows:
* A buy signal is given when +DI crosses above the -DI line.
* A sell signal is given when +DI crosses below the -DI line.

An ADX below 25 is a strong warning to avoid trading.

Calculation for Average Directional Index
DMP:= SUM(IF(HD>0 & HD>LD,HD,0),N);
DMM:= SUM(IF(LD>0 & LD>HD,LD,0),N);
PDI:= DMP*100/TR;
MDI:= DMM*100/TR;

so Calculation for ADX in MS Excel:
A = Company Name/date
B = Open
C = High
D = Low
E = close
F = Volumes

1. Calculate DM+/-:
a.If YH > = TH, and YL < = TL (i.e. if today's trading is totally within yesterday's range), then DM+ = 0;DM- = 0
so formula for (a)= IF(AND(C1>=C2,D1<=D2), "0",0)

b.If TH - YH = YL - TL (i.e. if the differences between highs and lows are the same), then DM+ = 0;DM- = 0
so formula for (b)= IF(AND(C2-C1=D2-D1),"0",0)

c.If TH - YH > YL - TL ( i.e. if the differences between highs and lows are the same), then DM+ = TH - YH;DM- = 0
so formula for (c)=IF(C2-C1>D2-D1), C2-C1, D2-D1)

d.Otherwise (i.e. the difference between lows is more than the difference between highs), DM+ = 0;DM- = YL - TL

Derived DM+/- formula in G2 is =IF(AND(C1>=C2,D1<=D2),0,IF(AND(C2-C1=D2-D1),0,IF(AND(C2-C1>D2-D1),C2-C1,D2-D1)))

for True range in cell H2 =MAXA(C2-D2,C2-E1,E1-C2,E1-D2,D2-E1)

for Plus DM in cell i2 =IF(G2>0,G2,0)
for minus DM in cell J2 =IF(G2<0,ABS(G2),0)

for PLUSDI in cell K2 =(I2*100)/H2
for MINUSDI in cell L2 =(J2*100)/H2

then Average 14day Plus DI,so in cell M14 =SUM(K2:K14)/13 (13 day sma)
in cell M15(14day EMA) =K15*0.133+M14*(1-0.133)

then Average 14day Minus DI,so in cell N14 =SUM(L2:L14)/13 (13 day sma)
in cell N15(14day EMA) =L15* 0.133+N14*(1-0.133)

Then DX in cell O14 =(M14-N14)/(M14+N14)*100
13day ADX in cell P27 =SUM(O14:O27)/13

Then (14)ADX in cell P28 =O28*0.133+P27*(1-0.133)

Pls note: replace "greater than" with symbol ">" and"less than" with symbol "<".if used any where.

since i am not a expert in excel programming,i would like to know,whether my Derived DM+/- formula in G2 is correct or not.

Sunday, November 25, 2007

Bollinger Bands

Bollinger Bands are a technical trading tool created by John Bollinger in the early 1980s.

The purpose of Bollinger Bands is to provide a relative definition of high and low.
Bollinger Bands consist of a set of three curves drawn in relation to securities prices.

The middle band is a measure of the intermediate-term trend, usually a simple moving average, that serves as the base for the upper and lower bands.

The interval between the upper and lower bands and the middle band is determined by volatility,typically the standard deviation of the same data that are used for the average.

The default parameters,are 20day (periods) and two standard deviations:

Middle Bollinger Band = 20-Day simple moving average
Upper Bollinger Band = Middle Bollinger Band + 2 * 20-period standard deviation
Lower Bollinger Band = Middle Bollinger Band - 2 * 20-period standard deviation

the interpretation of the Bollinger Bands is based on the fact that the prices tend to remain in between the top and the bottom line of the bands.

A distinctive feature of the Bollinger Band indicator is its variable width due to the volatility of prices.

In periods of considerable price changes (i.e. of high volatility) the bands widen leaving a lot of room to the prices to move in. During standstill periods, or the periods of low volatility the band contracts keeping the prices within their limits.

Bollinger bands are formed by three lines. The middle line (ML) is a usual Moving Average.

The top line, TL, is the same as the middle line a certain number of standard deviations (D) higher than the ML.
TL = ML+(D*StdDev)

The bottom line (BL) is the middle line shifted down by the same number of standard deviations.
BL = ML-(D*StdDev)

N is the number of periods used in calculation;
SMA = Simple Moving Average;
StdDev = means Standard Deviation.

It is recommended to use 20-period Simple Moving Average as the middle line, and plot top and bottom lines two standard deviations away from it.

To Calculate Bollinger Bands in MS Excel:.
Column,values to enter, formulas U have to enter
A = Company Name/date
B = Open
C = High
D = Low
E = LTP/close
F = Volumes

first we have to calculate a 20-day standard deviation:

G = here, we have to calculate mean (or Simple Mov. Aver.) of 20 days, we add all 20 days clsoing prices and divide it by 20.i.e no.of periods we in cell G21(20th day) u have to enter formula,it is =SUM(E2:E22)/20

then,we have to manually copy the mean (ie.Simple Mov. Aver.) of 20 days above the G21.till we complete 20 G21+19 cells above it.

H = then,we have to calculate deviation for these 20 day period so subract SMA from closing price we get deviation =E2-G2

I = then have to square the deviation so =POWER(H2,2)

J = standard deviation = then,we divide the sum of the squared deviation by the number of days so formula is =SQRT(SUM(I2:I21)/20)

Bollinger bands are formed by three lines.
G = Middle band

K = Upper band (SMA plus 2 standard deviations) =G21+(2*J21)

L = Lower band (SMA minus 2 standard deviations) =G21-(2*J21)

Even though Bollinger Bands can help generate buy and sell signals, they are not designed to determine the future direction of a security.

Bollinger Bands serve two primary functions:
-To identify periods of high and low volatility
-To identify periods when prices are at extreme, and possibly unsustainable, levels.

Remember that buy and sell signals are not given when prices reach the upper or lower bands. Such levels merely indicate that prices are high or low on a relative basis.

A security can become overbought or oversold for an extended period of time.

Finally,the bands are just bands,not signals.A band of the upper Bollinger Band is NOT a sell signal. A bands of the lower Bollinger Band is NOT a buy signal.

Relative Strength Index (RSI):Meaning &Calculation

Developed by J. Welles Wilder and introduced in his 1978 book, New Concepts in Technical Trading Systems, the Relative Strength Index (RSI) is an extremely useful and popular momentum oscillator.

The RSI compares the magnitude of a stock's recent gains to the magnitude of its recent losses and turns that information into a number that ranges from 0 to 100. Like most indicators, the RSI only needs one stock to be computed.

n = number of days
Average gain = (total gains/n)/(total losses/n)
For First RS = (Aver.Gain/Aver Loss)

If the RSI rises above 30 it is considered bullish for the underlying stock.
If the RSI falls below 70, it is a bearish signal.

Trading Signals & Divergences
Buy and sell signals can also be generated by looking for positive and negative divergences between the RSI and the underlying stock.

Positive divergence
Buy when price and the Relative Strength Index are both rising.
Sell when the price and the RSI are both falling.

Negative divergence
Buy when price falls and but RSI does not fall instead goes up.
Sell when the price goes up and but RSI does not go up instead falls by good margin

The underlying stock will often reverse its direction soon after such a divergence.

To Calculate Formula in Excel For RSI
Column,Description, = Formula To Enter,Cell No. to Enter
B=Open/Previous Close

To compute Gain/Loss:
G = % Change, =E3-E2, In G3 & AutoFill (Copy)( Press Shift +D on Kybrd)

To compute Gain only:
H= Advance, =IF(G3>0,G3,0) ,In H3 & AutoFill (Copy)( Press Shift +D on Kybrd)

To compute Loss only:
I= Decline, =IF(G3<0,G3,0) ,In I3 & AutoFill (Copy)( Press Shift +D on Kybrd)

To compute Average Gain:
J=Average Losses,=AVERAGE(H3:H16),In J16 & AutoFill (Copy)( Press Shift +D on Kybrd)

To compute Average Loss:
K=Average Losses,=AVERAGE(I3:I16),In K16 & AutoFill (Copy)( Press Shift +D on Kybrd)

L=For First RS,= (Aver.Gain/Aver Loss)
L=RS,=ABS(J16/K16),In L16 & AutoFill (Copy)( Press Shift +D on Kybrd)

M=RSI(14 day),=100-(100/1+RS)
M=RSI,=IF(K16=0,100,100-(100/(1+L16))),In M16 & AutoFill (Copy)( Press Shift +D on Kybrd)

MACD:Meaning &Calculation

Moving Average Convergence/Divergence (MACD)

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.

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 MACD in MS Excel:.

Column | Description | Formula 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 calculate ema

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


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

K = 2/(1+N)

so formula for 12day ema would be =E13*0.15+G12*(1-0.15) OR (0.15*(E13-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.formula steps once again:
we have to calculate 25-day Simple mov.aver(SMA).Formula= =Sum(E2:E26)/25 enter formula in H26

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 formula =H27-G27, enter in I27,copy the formula till latest closing price.

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.

Moving Averages:Meaning &Calculation

Moving Averages

Moving averages are one of the most popular and easy to use tools available to the technical analyst.A moving average series can be calculated for any time/data series.

In finance, it is most often applied to stock prices, returns or trading volumes. Moving averages are used to smooth out short-term fluctuations, thus highlighting longer-term trends or cycles.

Moving averages work best when a security is trending and are ineffective when a security moves in a trading range.

The two most popular types of moving averages are the Simple Moving Average (SMA) and the Exponential Moving Average (EMA).

Simple Moving Average (SMA)
A simple moving average is formed by computing the average (mean) price of a security over a specified number of periods.

The formula for a 10-day simple moving average of closing price is:
SMA = pM + pM-1 +pM-2 + ...+ pM-9/ 10

All moving averages are lagging indicators and will always be "behind" the price.

When prices are trending, moving averages work well. However, when prices are not trending, moving averages can give misleading signals.

If the price were rising, the SMA should be below the closing price to be considered bullish.

Exponential Moving Average (EMA)
In order to reduce the lag in simple moving averages, technicians often use exponential moving averages (also called exponentially weighted moving averages).

EMA's reduce the lag by applying more weight to recent prices relative to older prices. The weighting applied to the mostrecent price depends on the specified period of the moving average.

The shorter the EMA's period, the more weight that will be applied to the most recent price.

The formula for an exponential moving average is:
EMA = price today * k + Ema(previous)* (1-k)
X(EMA) = (K x (C - P)) + P

The simple moving average obviously has a lag, but the exponential moving average may be prone to quicker breaks.

Some investors prefer simple moving averages over long time periods to identify long-term trend changes.

Some traders prefer to use exponential moving averages for shorter time periods to capture changes quicker.

Simple moving averages work well for longer-term situations that do not require a lot of sensitivity.
Exponential moving averages are usually best for short-term situations that require a responsive moving average.

To calculate EMA,we have to first calculate the simple average...thats why i have to calculate SMA before EMA.

If you want a 10-day EMA,u have to calculate Simple Mov.Aver. for first 9 days i.e add up all closing prices and divide by 9.

From the 10th day the formula for EMA starts in..

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

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/Days in your EMA

The result will the same,but i prefer the first one.

K = 2/(1+N)
5 EMA =2/5+1=0.33
10 EMA =2/10+1=0.18
25 EMA =2/25+1=0.076
50 EMA =2/50+1=0.039
100 EMA =2/100+1=0.0198
200 EMA =2/200+1=0.00995

so for EMA formula would be like this:
5 EMA =E6*0.33+G5*(1-0.33)
10 EMA =AB25*0.18+AC24*(1-0.18)
25 EMA =E26*0.076+I25*(1-0.076)
50 EMA =E51*0.039+K50*(1-0.039)
100 EMA =E101*0.0198+M100*(1-0.0198)
200 EMA =E201*0.00995+O200*(1-0.00995)

for eg for 50 day EMA is
EMA = price today * k + EMA yesterday's * (1-k) =E51*0.039+L50*(1-0.039) = 894.6377071
X(EMA) = (K x (C - P)) + P =0.039*(E51-L50)+L50 =894.6377071

To Calculate Moving Average in MS Excel:.
Column | Description | Formula to enter
A = Company Name/date
B = Open
C = High
D = Low
E = LTP/close
F = Volumes

G = 5SMA =SUM(E2:E6)/5 ,enter in row cell 6 ,copy formula till last price
H = 5EMA =SUM(E2:E5)/4 , enter in row cell 5, =E6*0.33+H5*(1-0.33) ,enter in row cell 6, copy this formula till last price.

I = 25SMA =SUM(E2:E26)/25 ,enter in row cell 26, copy formula till last price
J = 25EMA =SUM(E2:E25)/24, enter in row cell 25, =E26*0.076+J25*(1-0.076) , enter in row cell 26, copy this formula till last price.

K = 50SMA =SUM(E2:E51)/50, enter in row cell 51, copy formula till last price
L = 50EMA =SUM(E2:E50)/49, enter in row cell 50 =E51*0.039+L50*(1-0.039) enter in row cell 51, copy this formula till last price

M = 100SMA =SUM(E2:E101)/100, enter in row cell 101, copy formula till last price
N = 100EMA =SUM(E2:E100)/99, enter in row cell100, =E101*0.0198+N100*(1-0.0198) enter in row cell 101, copy this formula till last price

O = 200SMA =SUM(E2:E201)/200,enter in row cell 201,copy formula till last price
P = 200EMA =SUM(E2:E200)/199,enter in row cell200,=E201*0.00995+P200*(1-0.00995), enter in row cell 201,copy this formula till last price

Trin:Intepretation & Calculation

Is short form for TRaders INdex. A technical analysis indicator calculated by taking the advances-to-declines spread and dividing that by the volume of advances to declines.

Founder of the TRIN
Richard W Arms, Jr., is a financial consultant to institutional investors and a private portfolio manager based in Albuquerque, New Mexico.

He is a noted expert in the field of technical and market analysis, the 1995 winner of the prestigious Market Technicians Award and the author of several best selling books and articles on his ground breaking theories in volume analysis and market forecasting.

This key technical tool for understanding market price movement is listed daily in the Wall Street Journal and is flashed once a minute on CNBC.

Richard Arms' revolutionary theories have changed the way investors perceive the market. His expertise in the field of technical analysis has had significant impact, evidence of this fact is his Equivolume charting system is now part of the most popular stock and futures software, and his Arms Index - also known as the Short-Term Trading Index or TRIN - has become one of the most important technical tools of Wall Street.

The Arms Index is primarily a short-term trading tool. The Index shows whether volume is flowing into advancing or declining stocks. If more volume is associated with advancing stocks than declining stocks, the Arms Index will be less than 1.0; if more volume is associated with declining stocks, the Index will be greater than 1.0.

The Index is usually smoothed with a moving average.A 4-day moving average is used for short-term analysis, a 21-day moving average for intermediate-term, and a 55-day moving average for longer-term analysis.

Normally, the Arms Index is considered bullish when it is below 1.0 and bearish when it is above 1.0. However, the Index seems to work most effectively as an overbought/oversold indicator.

When the indicator drops to extremely overbought levels, it is foretelling a selling opportunity. When it rises to extremely oversold levels, a buying opportunity is approaching.

What constitutes an "extremely" overbought or oversold level depends on the length of the moving average used to smooth the indicator and on market conditions.

Strictly defined, TRIN measures the ratio of advancing stocks to declining stocks and compares it to the ratio of advancing volume to declining volume.

When advancing volume exhibits discordance with the raw number of advancing stocks, the all-important signal is given. Conversely, when volume on the downside increases out of proportion with the number of declining stocks, an upside reversal is said to be imminent.

Interpreting TRIN
In a neutral market, TRIN will exhibit values within the range of 0.75 to 0.85, and its value typically remains below 1.0, which means the volume of advancing stocks exceeds the volume of declining stocks. This is considered typical because market participants are normally more bullish than bearish.

A high TRIN shows that bears are overoptimistic and that the market is nearing a bottom.
A low TRIN shows the opposite,the bulls are overoptimistic,the rally is unjustified and a market top is near.

But the situation is complicated somewhat because TRIN is handled differently in each of the different market conditions. Both overbought and oversold lines must be plotted at particular levels depending on the nature of the market.

For example,
In a bull market, 0.1--0.80 overbought& 0.80--1.++ oversold
In a bear market, 0.1--0.70 overbought& 0.70--1.++ oversold

the only time a value greater than 1.0 is used is in an oversold condition in a raging bull market.

The Arms Index is calculated by first dividing the number of stocks that advanced in price by the number of stocks that declined in price to determine the Advance/Decline Ratio. Next, the volume of advancing stocks is divided by the volume of declining stocks to determine the Upside/Downside Ratio. Finally, the Advance/Decline Ratio is divided by the Upside/Downside Ratio.

Trin is used for Indices only like Dowjones,NYSE, Calculate Trin in MS Excel:.
Column | Description | Formula
A = Date
B = Open/Previous Close
C = High
D = Low
E = LTP/Close Price
F = prev
G = trd qty
H = Turnover
I = Adv stks =IF((F2less thanE2),1,0) u have to enter formulae in I column 2nd row and copy it till 51st row
J = Decl.stks =IF((F2greater thanE2),1,0) u have to enter formulae in J column 2nd row and copy it till 51st row
K = Total Adv Stks =SUM(I2:I51) u have to enter formula in K column 51st row
L = Total Dec Stks =SUM(J2:J51) u have to enter formula in L column 51st row
M = Adv Volumes =IF(F2less thanE2,G2,0) u have to enter formulae in M column 2nd row and copy it till 51st row

N = Decl.Volumes =IF(F2greater thanE2,G2,0) u have to enter formula in N column 2nd row and copy it till 51st row
O = Total Adv.Volumes =SUM(M2:M51) u have to enter formula in O column 51st row
P = Total Decl.Volumes =SUM(N2:N51) u have to enter formula in P column 51st row
Q = Trin/The Arms Index =(K51/L51)/(O51/P51) u have to enter formula in Q column 51st row
R = Total Index Volumes =SUM(G2:G51) u have to enter formula in R column 51st row

pls change "greater than" and "less than" words with symbols "
>< ".