[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Adjustable Bollinger Bands



PureBytes Links

Trading Reference Links

Find some comments below:
--- In amibroker@xxxxxxxxxxxxxxx, "jtelang" <jtelang@xxxx> wrote:
> Hi Dimitris,
> 
> A bit confused about couple of things here... Hope you can clarify.
> 
> 1. BBands are calculated as standard deviation, so by definition, 2 
> times BBands is supposed to capture 95% of the values over periods 
> specified. 

No, it is not true. 
The percentage x is given by

Lookback=100;n=20;
bB=BBandBot(C,n,2);
bT=BBandTop(C,n,2);
x=100*Sum(C>=bB AND C<=bT,Lookback)/Lookback;

Explore your database and you will see that x is not equal to 95.
This is exactly what my code searches: to find the proper f that will 
make this percentage equal to 95%.

>In your formula below, if you make Lookback equal to n, 
> then theorotically the f min value should always be equal to 2, no 
> less, no more. Is that assumption correct? If yes, then couldn't 
you 
> simply calculate BBands over Lookback periods with 2 as multiplier, 
> giving you the same values as calculated below?
> 
> 2. In the for loop below, when you use "x[BarCount-1]" to compare, 
> what are you assuming BarCount value to be? "BarCount-1" will 
always 
> give you the last value in the array, no? 

I agree.

>Furthermore, as TJ 
> explained to me earlier in another thread, the BarCount value 
> fluctuates when QuickAFL mode is on. 

I didnīt follow this reply you refer but I donīt see anything 
flactuating in my results. Did you notice something similar ?

>So if you add "SetBarsRequired
> (10000, 10000)" at the top of your formula to correct it, you'll 
> notice that your min f value is a constant.

I do not use SetBarsRequired in this code.

To avoid confusion [?] with barcount, replace this line with

if(x[LastValue(Cum(1))-1]<=perc)

It will give the same result.
> TIA,
> 
> Jitu
In general, paste the code and see how it works [because it works] 
and then arrange it according to your standards.
Dimitris Tsokakis
> --- In amibroker@xxxxxxxxxxxxxxx, "Dimitris Tsokakis" 
<TSOKAKIS@xxxx> 
> wrote:
> > 
> > Paste in Inicator builder the
> > 
> > // Adjustable Bollinger bands
> > n=20;
> > Lookback=100;
> > perc=95;
> > for(f=1.5;f<3;f=f+0.01)
> > {
> > bB=BBandBot(C,n,f);bT=BBandTop(C,n,f);
> > x=100*Sum(C>=bB AND C<=bT,Lookback)/Lookback;
> > if(x[BarCount-1]<=perc)
> > {
> > g=f;
> > }
> > }
> > newbB=BBandBot(C,n,g);
> > newbT=BBandTop(C,n,g);
> > newperc=100*Sum(C>=newbB AND C<=newbT,Lookback)/Lookback;
> > Plot(C,"",1,64);Plot(newbB,"",colorLightYellow,8);Plot
> (newbT,"",colorLightYellow,8);
> > Plot(BBandBot(C,n,2),"",colorRed,1);Plot(BBandTop
> (C,n,2),"",colorRed,1);
> > Title="f min="+WriteVal(g,1.2)+",perc="+WriteVal(newperc,1.0)+"%";
> > 
> > The formula will find the f min necessary for the 95% confidence, 
> > will plot the new BBands and, for comparison, will plot the usual 
> f=2 BBlines.
> > It is interesting to see fminCSCO=2.09 but fminBEAS=2.70.
> > You may adjust n, Lookback and perc.
> > Dimitris Tsokakis


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Remanufactured Ink Cartridges & Refill Kits at MyInks.com for: HP $8-20. Epson $3-9, Canon $5-15, Lexmark $4-17. Free s/h over $50 (US & Canada).
http://www.c1tracking.com/l.asp?cid=6351
http://us.click.yahoo.com/0zJuRD/6CvGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/