Автор:
Разместил:   Дата: 2005-09-09 09:25
Комментарии: (0)   Рейтинг:

# Adaptive Stochastic Oscillator by Tushar Chande

Type : Indicator, Name : Adaptive Stochastic Oscillator

{--- (c) 2K Tushar Chande; Adaptive Stochastic Oscillator ---}

vars: v1(0), v2(0), v3(0), v4(0) ;
vars: lenmax(28), lenmin(7), currlen(0) ;
vars: hh(0), ll(0), stoch(0), stochma(0) ;

{--- Calculate 20-day std. Dev. And its 20-day range ---}

v1 = stddev(c,20) ;
v2 = highest(v1, 20) ;
v3 = lowest(v1, 20) ;

{--- Create v4: stochastic oscillator for 20-day std. dev. ---}
{--- if v1=v2 (highest level) => v4 = 1; if v1=v3 (lowest level) => v4=0 ---}

if (v2-v3) > 0 then v4 = ((v1 - v3)/(v2-v3)) Else v4 = 0 ;

{--- Calculate current effective length; if v4 = 1, then length = mininum ---}

currlen = IntPortion(lenmin + (lenmax-lenmin)*(1-v4)) ;

{--- Calculate stochastic oscillator and its 3-day exponential average ---}

hh = highest(h, currlen) ;
ll = lowest(l, currlen) ;
if (hh-ll) > 0 then stoch = ((close - ll)/(hh - ll)) * 100 ;
if currentbar = 1 then stochma = 0 else
stochma = 0.5*stoch + 0.5*stochma[1] ;

{--- Plot data ---}

plot1(stoch, "adapt_stoch") ;
plot2(stochma, "stochma") ;
plot3(80, "hi_ref") ;
plot4(20, "lo_ref") ;

{ --- End of code -}

Реклама:

Страница создана за 0.034 секунды