! Advance Decline Noncumulative
! Advancing Issues less Declining Issues divided by Total Issues.
! Also known as the Hughes Breadth index, the theory
! behind the index is that increases in stock prices are
! preceded by strengthening internals of the market and
! the reverse is true for decreases in stock prices.

Issues is [Adv Issues] - [Dec Issues].

TotalIssues is [Adv Issues] + [Dec Issues] + [Unch Issues].

ADNoncumulative is Issues/TotalIssues.

! Applying a 10-day moving average improves the
! bullish and bearish patterns

! A/D Ratio
! Works on markets only
! The A/D Ratio is similar to the Advancing-Declining Issues in
that it
! displays market breadth. The advantage of the Ratio is that it
remains
! constant regardless of the number of issues that are traded on
the
! New York Stock Exchange.

ADRatio is [Adv Issues] / [Dec Issues].

! A moving average of the A/D Ratio is often used as an
! overbought/oversold indicator. The higher the value, the more
! overbought the market is and the likelihood of a correction. Low
readings
! imply an oversold market andmay indicate a rally.
! Day-to-day fluctuations of the Advance/Decline Ratio
! can be smoothed by using the ratio with a moving average.

!DMI & ADX indicators as defined by Wells Wilder.
!Coded by Rich Denning on 6/12/00 !Error in code fixed by Bill Shalasha
on 8/25/01 (ZERO was added) !Bill added ADXR 8/25/01

Dailyrange is [high]-[low].
Ycloseh is abs(val([close],1)-[low]).
Yclosel is abs(val([close],1)-[high]).
Trange1 is Max(Dailyrange,Ycloseh).
Trange is Max(Trange1,Yclosel). define days 27. !NOTE: Wilder says
he is using a 14 day averaging method but if expontential averages
are used
! 27 days must be used to closely approximate his 14 days weighted
averaging method.

!+DM CODE: yhigh is val([high],1).
ylow is val([low],1).
rhigh is ([high]-yhigh).
rlow is (ylow-[low]).
DMplus is iff(rhigh > 0 and rhigh > rlow, rhigh, 0).
DMminus is iff(rlow > 0 and rlow >= rhigh, rlow, 0).
AvgPlusDM is expAvg(DMplus,days).
AvgMinusDM is expavg(DMminus,days).

!AVERAGE TRUE RANGE FOR ADX14 USE 27 DAYS WITH EXPAVG:
ATR is expAvg(Trange,Days).
!DMI CODE: PlusDMI is (AvgPlusDM/ATR)*100. !PLOT AS INDICATOR (2lines)
MinusDMI is AvgMinusDM/ATR*100. !PLOT AS INDICATOR (2 lines).

!ADX INDICATOR as defined by Wells Wilder
DIdiff is PlusDMI-MinusDMI. !PLOT DIdiff as historigram is same
as DirMov (AIQ built in indicator)
ZERO if PlusDMI = 0 and MinusDMI =0.
DIsum is PlusDMI+MinusDMI.
DX is iff(ZERO,100,abs(DIdiff)/DIsum*100).
ADX is ExpAvg(DX,days). !PLOT ADX as single line indicator with
support at 24 is same as ADX (AIQ)
! ADX Rate using the Least Means Squared method !Coded by Bill Shalasha
on 8/25/01
define periods 14.
n is HasDataFor(periods).
x is offsettodate(month(),day(),year()) + 1.
daysqr is x * x.
sumdaysqr is Sum(daysqr,n).
sumdays is Sum(x,n).
sumx is Sum( x * ADX ,n).
sumADX is Sum(ADX,n).
D is (sumdays*sumdays) - ( n * sumdaysqr).
ADXRate1 is ((n * sumx) - ( sumdays * sumADX)) / D.
ADXRate2 is slope2(ADX,periods).
ADXAIQ is [ADX].

AvgPd is 5.
TrueRange is max([high]-[low],max([high]-val([close],1),val([close],1)-[low])).
AvgTrueRange is SimpleAvg(TrueRange,AvgPd).
ATRR is avgtruerange / [close].

!MOVING AVERAGES FOR PRICE, VOLUME, VELOCITY, & RATE OF CHANGE coded
by Rich Denning 8/4/01

define ST 17.
define IT 50.
define LT 200.
define eST 10.
define eIT 20.
define eLT 49.

!Short term simple moving average [ST MA]
STMA is simpleavg([close],ST).
!Intermediate term simple moving average [IT MA]
ITMA is simpleavg([close],IT).
!Long term simple moving average [LT MA]
LTMA is simpleavg([close],LT).
!Short term exponential moving average [ST ESA]
STESA is expavg([close],eST).
!Intermediate term exponential moving average [IT ESA]
ITESA is expavg([close],eIT).
!Long term exponential moving average [LT ESA]
LTESA is expavg([close],eLT).
!Volume exponential moving average [Volume ESA]
VolumeESA is expavg([volume],50).
!Velocity indicator [Velocity]
Velocity21 is slope([close],21).
!RateOfChange for X days (custom indicator) !Plot as line indicator
on charts with zero line support
!One day rate of change
ROC1 is ([close]/val([close],1)-1)*100.
!Two day rate of change, etc...
ROC2 is ([close]/val([close],2)-1)*100.
ROC5 is ([close]/val([close],5)-1)*100.
ROC10 is ([close]/val([close],10)-1)*100.
ROC15 is ([close]/val([close],15)-1)*100.
ROC20 is ([close]/val([close],20)-1)*100.
ROC50 is ([close]/val([close],50)-1)*100.
ROC100 is ([close]/val([close],100)-1)*100.
ROC200 is ([close]/val([close],200)-1)*100.

B is [close] - [open].
Bgreater is b>0.
Blessthan is b<0.
Bup is sum(bgreater,14).
Bdn is sum(blessthan, 14).
BodyMomentum is (bup / (bup + bdn)) * 100.

BodyMomentumOscillator is simpleavg(bodymomentum, 3).

!BOLLINGER BANDS
!coded by Rich Denning on 8/12/01 with help from tv
!Set parameters:
Define L 20. !Default is 20
Define Factor1 2. !Default is 2
Define Factor2 2. !Default is 2
!Standard Deviation of the close is the square roor of variance
of the close is:
Variance is Variance([close],L).
StdDev is Sqrt(Variance).
!Middle Band SMA is simpleavg([close],L).
!Upper Bollinger Band UpperBB is SMA + Factor1 * StdDev. !!Plot
as single line indicator on chart
!Lower Bollinger Band LowerBB is SMA - Factor2 * StdDev. !!Plot
as single line indicator on chart

n is 8.
!change the "n" value above to any # of days you want.
M is ([high] + [low] + [close]) / 3.
avgm is simpleavg(M,n). absdiff is abs(M-avgm).
sumD is sum(absdiff,n) * (1 / n).

CongestionIndex is (((hival([close], 80)) - (loval([close], 80)))
/ (loval([close], 80))) * 100.
CongestionIndex5daysago is valresult(congestionindex, 5).
close is [close].
HighestHigh80 is highresult(close, 80).
HighestHigh80offset5 is highresult(close, 80, 5).
MovAvgVol5days is simpleavg([volume], 5).
MovAvgVol60days is simpleavg([volume], 60).
MovAvgVol60offset5 is highresult([volume], 60, 5).
MovAvgClose5days is simpleavg(close, 5).
Consolidationbreakout if (congestionindex5daysago < 10) and (congestionindex
>=10) and (close > highesthigh80offset5) and
(movavgvol5days >= (1.5
* movavgvol60offset5)).

MovAvg55 is simpleavg([close], 55).
MovAvg55offset15 is simpleavg([close], 55, 15).
LowestMovAvg55 is lowresult((movavg55 - movavg55offset15), 14).
HighestMaAvg55 is highresult((movavg55 - movavg55offset15),14).

!!! Front Weighted 36 Day Moving Average is similar to all other
moving averages.
!!! The interpretation is just like with all the others, the trend
is up when prices are
!!! above the moving average and the trend is down when prices are
below the
!!! moving average. This particular variation attempts to weight
the data at the front more
!!! than that at the back, with a sliding scale for each Trading
days value.
Bar34 is val([close], 34) * 0.01.
Bar33 is val([close], 33) * 0.01.
Bar32 is val([close], 32) * 0.01.
Bar31 is val([close], 31) * 0.01.
Bar30 is val([close], 30) * 0.01.
Bar29 is val([close], 29) * 0.01.
Bar28 is val([close], 28) * 0.01.
Bar27 is val([close], 27) * 0.01.
Bar26 is val([close], 26) * 0.01.
Bar25 is val([close], 25) * 0.02.
Bar24 is val([close], 24) * 0.02.
Bar23 is val([close], 23) * 0.02.
Bar22 is val([close], 22) * 0.02.
Bar21 is val([close], 21) * 0.02.
Bar20 is val([close], 20) * 0.02.
Bar19 is val([close], 19) * 0.02.
Bar18 is val([close], 18) * 0.02.
Bar17 is val([close], 17) * 0.03.
Bar16 is val([close], 16) * 0.031.
Bar15 is val([close], 15) * 0.031.
Bar14 is val([close], 14) * 0.031.
Bar13 is val([close], 13) * 0.031.
Bar12 is val([close], 12) * 0.031.
Bar11 is val([close], 11) * 0.031.
Bar10 is val([close], 10) * 0.031.
Bar9 is val([close], 9) * 0.031.
Bar8 is val([close], 8) * 0.031.
Bar7 is val([close], 7) * 0.006.
Bar6 is val([close], 6) * 0.006.
Bar5 is val([close], 5) * 0.07.
Bar4 is val([close], 4) * 0.07.
Bar3 is val([close], 3) * 0.07.
Bar2 is val([close], 2) * 0.07.
Bar1 is val([close], 1) * 0.07.
Bar0 is [close] * 0.079.
OneFrontWeighted36BarMA1 is bar34 + bar33 + bar32 + bar31 + bar30
+ bar29 + bar28 + bar27 + bar26 + bar25 + bar24 + bar23 + bar22
+ bar21 + bar20 + bar19 + bar18.
TwoFrontWeighted36BarMA2 is bar17 + bar16 + bar15 + bar14 + bar13
+ bar12 + bar11+ bar10 + bar9 + bar8 + bar7 + bar6 + bar5 + bar4
+ bar3 + bar2. ThreeFrontWeighted36BarMA3 is bar1 + bar0.

FrontWeighted36DayMA is OneFrontWeighted36BarMA1 + TwoFrontWeighted36BarMA2
+ ThreeFrontWeighted36BarMA3.

! keltner///upper and lower Trading
bands, overbought and oversold areas...cuts through
! upper is a sell point, and crossing lower is a buy point.

Price is [close].
MA is 8.
Constant is 1.3.
TrueRange is [high] - [low].
CentLine is SimpleAvg(price, MA).
AvgRange is SimpleAvg(TrueRange, MA).
Upper is Centline + (AvgRange * Constant).
Lower is Centline - (AvgRange * Constant).

HighestHigh5 is hival([high], 5).
LowestLow5 is loval([low], 5).
Close is [close].
X is highesthigh5 - val([open], 5).
Y is close - lowestlow5.
LSS5day is 100* (x + y) / (highesthigh5 - lowestlow5) * 2.
LSSdiff3 is LSS5day - valresult(lss5day, 3).

Define S 12.
Define L 25.
Define X 9.
ShortMACDMA is expavg([Close],S).
LongMACDMA is expavg([Close],L).
MACDValue is ShortMACDMA-LongMACDMA.
SignalMACD is expavg(MACDValue,X).

Volume is [volume] /10000.
Rule1 if [close]> val([close],1) and [volume]> val([volume],1).
Rule2 if [close]< val([close],1) and [volume]< val([volume],1).
MP1 is iff(rule1, volume,0).
MP2 is iff(rule2, -volume,MP1).
MP is sum(mp2,7) *4 + sum(mp2,14) *2 + sum(mp2,28) .

Define days 4.
Close is [close].
Yclose is val([close],1).
PVF is iff(close>yclose,1,0).
NVF is iff(close<=yclose,1,0).
AvgPrice is ([high]+[low]+close)/3.
MF is [volume]*AvgPrice.
PMF is Sum(MF*PVF,days).
NMF is Sum(MF*NVF,days).

!! 7-days here is equivalent
to a 4-day RSI Wilder in charts
!! 9-days here is equivalent to a 5-day RSI Wilder in charts
!!13-days here is equivalent to a 7-day RSI Wilder in charts
!! 27-days here is equivalent to a 14-day RSI Wilder in charts
Define days 7.
U is [close]-val([close],1).
D is val([close],1)-[close].
AvgU is ExpAvg(iff(U>0,U,0),days).
AvgD is ExpAvg(iff(D>=0,D,0),days).

!!! Natenberg's Volatility
-- Defined as the standard deviation of the logarithmic price
changes
!!! measured at regular intervals of time. From Sheldon Natenberg's
book "Option Volatility and Pricing".

Close is [close]. Yclose is val([close], 1).
Log is ln(close / yclose).

NatenbergsVolatility is sqrt(variance(log, 10)) * sqrt(365).

Define L 21. !(Default=21)
Define S 10. !(Default=10)
Define PctK 10. !(Default=10)
Define PctD 10. !(Default=10) !Plot as line with 80/20 lines =
Stochastic
Stoch is 100*(([close] - loval([low],L)) / (hival([high],L) -
loval([low],L))).
FastK is SimpleAvg(Stoch,L).
FastD is SimpleAvg(FastK,S).

!Plot as two line indicator = SK-SD
SK is SimpleAvg(Stoch,PctK).
SD is SimpleAvg(SK,PctD).

!!! The ST Oscillator
is a momentum indicator and plts very similiar to the "Chande
Momentum
!!! Oscillator" with the difference being the STOsc does not swing
as far as the CMO.

Define LB 5.
Num is [close] - val([close], 1).
Den is [high] - [low].
MovNum is simpleavg(num, lb).
MovDen is simpleavg(den, lb).
MN is iff(movnum = 0, 0.01, movnum).
MD is iff(movden = 0, 0.01, movden).

!!! Stochastic Momentum
Oscillator
Close is [close].
HighValue is hival([high], 13).
LowValue is loval([low], 13).
Define1 is (close) - (0.5 * (highvalue + lowvalue)).
Define2 is highvalue - lowvalue.
ExpavgDefine1 is expavg(define1, 2).
ExpavgDefine2 is expavg(define2, 2).

StochasticOscillator is ((expavgdefine1) / (0.5 * define2)) *
100.

!STOCHASTIC RSI
!From Opening Bell 2/2002
!In charts the parameter for the RSI Wilder must be set to the
desired value; default is 14
Define p 14.
StochRSIob is ([RSI Wilder] - loval([RSI Wilder],p)) /(hival([RSI
Wilder],p) -loval([RSI Wilder],p)) * 100.
!!RSI Wilder (Coded by Rich Denning).
!The following will allow you to set the RSI Wilder parameter
in the EDS without having to worry how it is set in the charts:
!! 7-days here is equivalent to a 4-day RSI Wilder in charts
!! 9-days here is equivalent to a 5-day RSI Wilder in charts !!
13-days here is equivalent to a 7-day RSI Wilder in charts
!! 27-days here is equivalent to a 14-day RSI Wilder in charts
Define days 27. !!!! 27 is same as default of 14 in charts
U is [close]-val([close],1).
D is val([close],1)-[close].
AvgU is ExpAvg(iff(U>0,U,0),days).
AvgD is ExpAvg(iff(D>=0,D,0),days).
RSIw is 100-(100/(1+(AvgU/AvgD))).

!!STOCHASTIC RSI with hard coded RSI:
StochRSI is (RSIw - lowresult(RSIw,p)) /(highresult(RSIw,p) -
lowresult(RSIw,p)) * 100.

!! TCI Indicator Hard-Coded.
n1 is 10.
!! Channel periods.
n2 is 21.
!! Average periods.
AP is ([high] + [close] + [low]) / 3.
ESA is expavg(AP, n1).
D is expavg(abs(AP - ESA), n1).
CI is (AP - ESA) / (0.015 * D).

!!! True Strength Index
ROC1day is [close] - val([close], 1).
AvgROC25 is expavg(roc1day, 25).
ExpAvg13AvgROC25 is expavg(avgroc25, 13).
ABSRoc is abs(roc1day). ExpAvgABSRoc is expavg(absroc, 25).
ExpAvg13ExpAvgABSRoc is expavg(expavgabsroc, 13).

TrueStrengthIndex is ((ExpAvg13AvgROC25) / (ExpAvg13ExpAvgABSRoc))
* 100.
ExpMovAvgTSI is expavg(truestrengthindex, 20).

Close is [close].
Yclose is val([close], 1).
CMO1 is iff(close > yclose, close - yclose, 0).
SumCMO1 is sum(cmo1, 14).
CMO2 is iff(close < yclose, yclose - close, 0).
SumCMO2 is sum(cmo2, 14).

!!! Tushar Chande's
Target Price
Close is [close].
Yclose is val([close], 1).
A is simpleavg(abs(close - yclose), 20).
TPH1 is close + A.
TPH2 is close + (2 * A).
TPL1 is close - A.
TPL2 is close - (2 * A).

!!! Tushar Chande's
Trendscore
Close is [close].
Close11 is val([close], 11).
Close12 is val([close], 12).
Close13 is val([close], 13).
Close14 is val([close], 14).
Close15 is val([close], 15).
Close16 is val([close], 16).
Close17 is val([close], 17).
Close18 is val([close], 18).
Close19 is val([close], 19).
Close20 is val([close], 20).

!!! Tushar Chande's
Vidya
close is [close].
yclose is val([close], 1).
StdDev is sqrt(variance(close, 5)).
MAStdDev is simpleavg(stddev, 20).
SC is 0.9.
K is stddev / mastddev.

define n 21.
AccumFac is (([close]-[low]) - ([high]-[close])) / ([high]-[low]).
VolumeSum is sum([volume],n).
VolumeAccum is sum([Volume] * AccumFac,n).

!Plot as historigram with zero line
VApct is VolumeAccum / VolumeSum * 100.

!!Hard-Coded Volatility
Indicator
!! set "n" to any # of days.
Define n 21.
dp is Ln([Close] / val([close],1)).
sumdp is Sum(dp,n).
sumdpsqr is sumdp * sumdp.
sumdpave is sumdpsqr / n.
dpsqr is Ln([Close] / val([close],1)) * Ln([Close] / val([close],1)).
totdpsqr is Sum(dpsqr,n).
diff is totdpsqr -sumdpave.
!!use 250 for daily, or 52 for weekly below
factor is 250 / (n-1).
result is sqrt(diff * factor).
Volatility1 is result * 100.

EMA1 is expavg([close], 13).
EMA2 is expavg([close], 21).
Difference is ema1 - ema2.
ZeroLagEMA13 is ema1 + difference.
EMA3 is expavg([close], 21).
EMA4 is expavg([close], 21).
Difference1 is ema3 - ema4.
ZeroLagEMA21 is ema3 - difference.