log in     sign up for free
 
Don't worry about what the markets are going to do, worry about what you are going to do in response to the markets.
Michael Carr
 
 
Home
systems (285)
 
 
Special offer: buy AmiBroker and EOD+Real-Time Data
Formula Library
 
AmiBroker
MetaTrader
MetaStock
TradeStation
Wealth-Lab
NinjaTrader
 
add your formula
System Library
 
 
Account login
Your email:
Password:
 
Log in
New to s4t? Sign up.
If you forgot your password click here.
Search the Web
 
Custom Search

Adaptive Stochastic Oscillator

Formula for: TradeStation

indicator

 

 

Views:  2936

Added: December 02, 2006
 
Rate this code:  Rate: 1 Rate: 2 Rate: 3 Rate: 4 Rate: 5
This formula has not been rated yet
 

email this link

 
 
Tags: TradeStation, indicator
 


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.

Tushar Chande, Ph.D., of Tuscarora Capital Management, is a Contributing Editor to STOCKS & COMMODITIES.

 

 



Code:

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


 





Code to difficult? Find somebody to help you with coding here.

 



Author: Tushar Chande
Source: TASC

 

View similar (indicator for TradeStation):

VIDYA
Better Volume Indicator
Reverse Engineering
Balance Of Power (BOP)
MACD RS
TAStoch Indicator
## Top & Bottom Indicator
One Point Two Eight
Color on MACD Histogram II
RMI Indicator
...
 
 
all formulas for TradeStation
all formulas

 

 

Email to friend

Top

 

     
However we try to maintain hiqhest possible level of service - most formulas, oscillators, indicators
and systems are submitted by anonymous users.
Therefore S4T™ does not take any responsibility for it's quality.
If you use any of this information, use it at your own risk. You are responsible for your own trading decisions.
Be sure to verify that any information you see on these pages is correct, and is applicable to your particular trade.
In no case will S4T™ be responsible for your trading gains or losses.
PayPalSecure payments by PayPal S4T™ is a part of TAURO EDUCATION NETWORK
 
Privacy note | (c) copyrights systems4trading.com 2006-2009