MetaStock™ Zone Tworzenie Sytemów Trader Shop Forum & FAQ Artykuły Linki Elliott Waves EasyLanguage™ Zone

 

Adaptive Stochastic Oscillator by Tushar Chande

ADAPTIVE INDICATORS

Editor,

I know there's such a thing as adaptive moving averages. I was wondering if anyone has come up with other adaptive indicators, such as an adaptive RSI or adaptive stochastics. Is there a way to turn indicators such as these into adaptive ones, or is it possible to use an adaptive moving average on them? If so, could you give me an example of how to do so?

Richard Knapik, via E-mail

Tushar Chande replies:

I was the first to propose adaptive indicators, and my article "Stochastic RSI And Dynamic Momentum Index" (STOCKS & COMMODITIES , December 1992) explains how to do it. My book The New Technical Trader (John Wiley & Sons) also contains a good explanation of it. The strategy is to change the lookback length of the indicator by connecting it to market volatility. We would like the indicator to have a long lookback period when prices are in a trading range (volatility is low). Conversely, we want a short lookback length when prices are moving rapidly. I feel that changing the lookback length for calculating indicators is more responsive than smoothing them with adaptive moving averages. The actual definition of long and short lookback lengths depends on your trading horizon.

Here is some simple TradeStation code to create an adaptive stochastic oscillator that uses the 20-day standard deviation of closing prices to vary the length between seven and 28 days. First, determine if the 20-day standard deviation is at its highest level. To do so, compute a stochastic oscillator using the 20-day standard deviation (variables v1 through v4). If the 20-day standard deviation is at its highest level (v1=v2), then v4=1 and the oscillator length is set at its shortest value, that is, set to the variable lenmin (=7 days). If the 20-day standard deviation is at its lowest value (v1=v3), then v4=0 and the current length is set to the maximum length, that is, the variable lenmax (= 28 days). All that remains is to calculate the stochastic oscillator, Stoch, for the close and smooth it using a three-day exponential moving average. The same approach can be used to develop other adaptive indicators or averages.


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 --}

 

t-i-Adaptive_Stochastic_Oscillator.gif
 
Tushar Chande, Ph.D., of Tuscarora Capital Management, is a Contributing Editor to STOCKS & COMMODITIES.
Source / From: TOP
TASC

Equis and MetaStock® and MetaStock Professional® are registered trademarks of Equis International. Achelis Binary Wave®, The DownLoader®,
Expert Advisor®, OptionScope®, Quotecenter® and Smart Charts® are trademarks of Equis International, a Thomson Reuters company.

TradeStation® Pro, TradeStation® 2000i, OptionStation®, SuperCharts®, PowerEditor® and EasyLanguage®
are registered trademarks of TradeStation Technologies, Inc. Other names and marks referred to are the property of their respective owners.

All information provided on this website is for educational purposes only. Trading involves risk, including possible loss of principal and other losses.

Ten i inne materiały na tej stronie zostały zamieszczone zostały jedynie w celach edukacyjnych, nie ponoszę żadnej odpowiedzialno¶ci za ich stosowanie.

Gra na giełdzie niesie ze sob± ryzyko poważnych strat finansowych!