Welcome Features News Download Registration Support FAQ Wish list Links
Advanced stock charting and analysis program

AFL Library

This is read-only version of AFL library entry. Ability to add user formulas and comment is only available from members-only area.

Details:

Formula name: Adaptave Zones O/B & O/S Oscillator
Author/Uploader: Anthony Faragasso - ajf1111 [at] epix.net
Date/Time added: 2001-12-27 10:22:54
Origin:
Keywords:
Level: medium
Flags: indicator

DISCLAIMER: Most formulas present in AFL on-line library are submitted by the users and are provided here on an "as is" and "as available" basis. AmiBroker.com makes no representations or warranties of any kind to the contents or the operation of material presented here. We do not maintain nor provide technical support for 3rd party formulas.
Description:

Automatically Adjusts the Overbought and Oversold levels based on past performance.( Lookback ).
Set up to be used with AmiBroker PrePackaged indicators,RSI,CCI,STOCHK,STOCHD,MFI,ULTIMATE,ROC,
Also, Added RSI of MACD indicator.
User Friendly, Set with Vairable Identifiers and information in the title as to what indicator is being studied.

A1=RSIt; B2=RSI(pds); C3=CCI(pds); D4=StochK(pds); E5=StochD(pds);
F6=MFI(pds); G7=Ultimate(pds); H8=ROC(C,pds);

Osc=C3; /*insert variable by Identifier*/

Further Improvements will be Added to Enhance.

Formula:

/*Adaptive Zones OB/OS OSCILLATOR*/
/*Automatically Adjusts the overbought and oversold levels based on past
performance*/
/*Interpreted and coded by Anthony Faragasso*/
/*Can be used with PrePackaged
indicators,RSI,CCI,STOCHK,STOCHD,MFI,ULTIMATE,*/
/*For ROC add the Close. ex.ROC(C,pds);*/

MaxGraph=10;
/*Input */
Lookback=60;
PerCent=95;
Pds =14;

/****Dimitri Code***********/
/*14-Day RSI of MACD()*/ 
//t=14; Replaced with pds= statement
Var=MACD(); 
Up=IIf(Var>Ref(Var,-1),abs(Var-Ref(Var,-1)),0); 
Dn=IIf(Var<Ref(Var,-1),abs(Var-Ref(Var,-1)),0); 
Ut=Wilders(Up,Pds); 
Dt=Wilders(Dn,Pds);
RSIt=100*(Ut/(Ut+Dt)); 
/************End Code*************************/

/*******Variables******************/

A1=RSIt; B2=RSI(pds); C3=CCI(pds); D4=StochK(pds); E5=StochD(pds);
F6=MFI(pds); G7=Ultimate(pds); H8=ROC(C,pds);


Osc=C3; /*insert variable by Identifier*/ 

/*Value of Osc*/
Value1 = Osc;

/*Highest AND Lowest Values of Osc during Lookback Period*/
Value2 = HHV(Value1,Lookback);
Value3 = LLV(Value1,Lookback);

/*Range of Osc during Lookback Period*/
Value4 = Value2 - Value3;

/*Define PerCent of Range to determine OB AND OS levels*/
Value5 = Value4 * (PerCent / 100);

/*Calculate OB AND OS levels*/
Value6 = Value3 + Value5;
Value7 = Value2 - Value5;

baseline=IIf( Osc < 100 AND Osc > 10 ,50 ,IIf( Osc < 0 ,0,0));

Header=WriteIf(Osc==A1," RSI Of MACD",WriteIf(Osc==b2," RSI",WriteIf(Osc==C3,"
CCI",WriteIf(Osc==D4,"STOCHK",WriteIf(Osc==E5,"STOCHD",WriteIf(Osc==F6," MONEY
FLOW INDEX",WriteIf(Osc==G7," ULTIMATE",WriteIf(Osc==H8,"
ROC(CLOSE)",""))))))));

Plot(Value1, Header,6,1+4); /*BLUE*/
Plot(Value6," O/B",4,1+4);  /*RED -TOP(SELL)*/
Plot(Value7," O/S",5,1+4);  /*GREEN-BOT(BUY)*/
Plot(Baseline," Baseline",7,1+4); /* yellow*/

Comments:

Anthony Faragasso
ajf1111 [at] epix.net
2001-12-27 10:29:21
*******Adaptive Zones OB/OS OSCILLATOR********
1. Automatically Adjusts the Overbought and Oversold levels based on past performance.( Lookback ).
The closer the lookback period ( ex. 25, which I like with the RSI ) the more responsive the Zones become.( short term trading ).
2. You can set the sensitivity of the Zones.( ex. 95, 85,80, etc.) Percent. Then interpret the signals as you would with other oscillators.
a) Buy when the oscillator falls below a specific level and then rises above that level.
b) Sell when the oscillator rises above a specific level and then falls below that level.
c) Look for Divergences. ( Ex. When prices are making a series of new highs and the oscillator is failing to surpass it previous highs.
3. Instead of the arbitrary ( 30,70 ) , ( 20,80 ) etc. The Adaptive Zones Automatically adjust the OverBought and OverSold Levels Based on past performance of
the derivitive , which is set with the Lookback Variable ( 60 or closer( 25), seems to give a good interpretation of
current market conditions ) and your Percent setting, giving optimal o/b and o/s levels.
A setting of percent=95, is extreme Buy and sell levels, When the oscillator touches the Top
zone and then Turn down ( Possible Sell ), and when the oscillator touches the Bottom Zone
and Turns up ( Possible Buy ).
4. If Oscillator is continually above the Baseline, market in an uptrend, If Oscillator is continually
Below the Baseline, Market in a Downtrend.
Pal Anand
palsanand [at] yahoo.com
2002-09-20 03:22:31
This is a great Cycle identifier. Instead of waiting for the oscillator to turn down for sell or turn up for buy, I use the raw value as filters for picking tops and bottoms by combining with my primary trading system which identifies all kinds of signals in all kinds of market conditions. Most useful for CCI, RSI(MACD), ULTIMATE and ROC(CLOSE), because these do not have a well defined range unlike the other oscillators like MFI, RSI, STOCH which oscillate between 0 and 100. Also if the formulas for ATR, Chaikin Oscillator, Chaikin Volatility, Ease of Movement, Herricks Payoff Index, Index of Candle Strength, On Balance Volume, Price and Volume Trend, Trend Intensity Index, Balance of Power, Negative/Positive Volume Index, Williams %R, A/D and Beta are included it would be fantastic. Can help with the text version of explanations for these formulas to facilitate coding using AFL.
Cristian
ctoma [at] attcanada.net
2003-05-21 02:07:16
Hi,
I have a few things that I don't understand that well. I will quote from the description you gave:
"Set up to be used with AmiBroker PrePackaged indicators,RSI,CCI,STOCHK,STOCHD,MFI,ULTIMATE,ROC,Also, Added RSI of MACD indicator.
User Friendly, Set with Vairable Identifiers and information in the title as to what indicator is being studied.
The closer the lookback period ( ex. 25, which I like with the RSI ) the more responsive the Zones become.( short term trading ).
You can set the sensitivity of the Zones.( ex. 95, 85,80, etc.) Percent."
1) How do I use it with different indicators?
2) How do I change the lookback period?
3) How can I change the sensitivity of the zones?
Do I do all these by manipulating the formula?
Thanks,
Cristian
Dennis
AmiBroker at PzzAzz point com
2005-09-23 04:22:03

About 5 lines down look for this:

MaxGraph=10;
/*Input */
Lookback=60;
PerCent=95;
Pds =14;
ali H

2006-01-18 05:41:07
I think this is a great indicator

Thank you very much
AFROZ
affroz [at] gmail.com
2007-01-23 04:06:45
it is extremely useful piece of code.
can u please modify it in such a way that it can run a scan and generate a list of oversold or over brought stocks.
Bosh

2007-01-24 19:32:16
AFROZ, Here you are, with thanks to Anthony for the original code. I've added
the analysis and made it a bit more user friendly via right click->Parameters.
Try out the other oscillators. Also, once you enter a trade, watch out for the
situations where the market goes against you before the oscillator reaches the
Sell or Cover exits, as this code doesn't protect you.

--- snip here ---

Version(4.70);// You must use a version greater than this one
Lookback=Param("Lookback",60,10,90,1);
PerCent=Param("Pecentage of range",95,10,120,5);
Pds=Param("Period",14,7,33,1);

Var=MACD();
Up=IIf(Var>Ref(Var,-1),abs(Var-Ref(Var,-1)),0);
Dn=IIf(Var<Ref(Var,-1),abs(Var-Ref(Var,-1)),0);
Ut=Wilders(Up,Pds);
Dt=Wilders(Dn,Pds);
RSIt=100*(Ut/(Ut+Dt));

A1=RSIt;
B2=RSI(pds);
C3=CCI(pds);
D4=StochK(pds);
E5=StochD(pds);
F6=MFI(pds);
G7=Ultimate(pds);
H8=ROC(C,pds);

oc=ParamList("Oscillator choice",
"RSI of MACD|RSI|CCI|StochK|StochD|Money Flow Index|Ultimate|ROC(Close)",
2);
Osc=
IIf(oc=="RSI of MACD",A1,
IIf(oc=="RSI",B2,
IIf(oc=="CCI",C3,
IIf(oc=="StochK",D4,
IIf(oc=="StochD",E5,
IIf(oc=="Money Flow Index",F6,
IIf(oc=="Ultimate",G7,H8))))))); // else ROC

V2=HHV(Osc,Lookback); // Highest AND Lowest Values of Osc during Lookback Period
V3=LLV(Osc,Lookback);
V4=V2-V3; // Range of Osc during Lookback Period
V5=V4*(PerCent/100); // Define PerCent of Range to determine OB AND OS levels
V6=V3+V5; // Over Bought level
V7=V2-V5; // Over Sold level

Buy=Cross(Osc,V7) AND Osc > Ref(Osc,-1);
Sell=Cross(Osc,V6) AND Osc > Ref(Osc,-1);
Short=Cross(V6,Osc) AND Osc < Ref(Osc,-1);
Cover=Cross(V7,Osc) AND Osc < Ref(Osc,-1);

// Exploration ...
Filter=Buy OR Sell OR Short OR Cover;
AddColumn(Buy,"Buy",1,colorDefault,IIf(Buy,colorPaleGreen,colorDefault));
AddColumn(Sell,"Exit buy",1,colorDefault,IIf(Sell,colorPink,colorDefault));
AddColumn(Short,"Short",1,colorDefault,IIf(Short,colorPaleGreen,colorDefault));
AddColumn(Cover,"Exit short",1,colorDefault,IIf(Cover,colorPink,colorDefault));
AddColumn(Osc, oc+" Lvl");
AddColumn(V6, "O/B Lvl");
AddColumn(V7, "O/S Lvl");

Plot(Osc, oc,ParamColor("Oscillator",colorBlue),styleLine);
Plot(V6," O/B",ParamColor("Upper - Sell",colorRed),styleLine);
Plot(V7," O/S",ParamColor("Lower - Buy",colorGreen),styleLine);
Plot(IIf(Osc<100 AND Osc>10,50,0)," Baseline",ParamColor("Baseline",colorYellow),styleLine);


About | Privacy | Terms of Use | Contact information
Copyright © 2001 AMIBROKER.COM