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

[amibroker] Re: Adjustable Bollinger Bands



PureBytes Links

Trading Reference Links

Anthony
Assuming I've understood your logic, These 2 lines, I think should 
be +/- 50% of shift?
avg2=avg1+shift;
avg3=avg1-shift;

ie avg2=avg1+0.5*shift;
avg3=avg1-0.5*shift;

Just another question, why sum EMA over Pds and divide by pds, 
doesn't this just slow it down & smooth it considerably.  ie a 
simple MA of the EMA.  
Sum(EMA(C,pds),pds)/pds;

I must admit I modified your code so that I used a simple MA that I 
could independently select the periods for. 

MApds =Param("MA periods", 20,10,200,1);
avg1=MA(C,MApds);  

ps. love the straight forward simplicity of your afl.

Andrew

--- In amibroker@xxxxxxxxxxxxxxx, "Anthony Faragasso" <ajf1111@xxxx> 
wrote:
> Rick,
> 
> //Percent envelopes
> 
> pds =Param("periods", 20,10,40,1);
> 
> percent=Param("Percent",95,10,100,5);
> 
> 
> 
> Value2=Sum(HHV(H,pds),pds)/pds;
> 
> Value3=Sum(LLV(L,pds),pds)/pds;
> 
> range=Value2 - Value3;
> 
> shift = range * (PerCent / 100);
> 
> 
> 
> avg1=Sum(EMA(C,pds),pds)/pds;
> 
> avg2=avg1+shift;
> 
> avg3=avg1-shift;
> 
> topband=avg2;
> 
> midline=avg1;
> 
> botband=avg3;
> 
> Plot(C,"Close",colorBlack,styleCandle);
> 
> Plot(topband,"tobBand",colorRed,styleLine);
> 
> Plot(midline,"Midline",colorYellow,styleLine);
> 
> Plot(botband,"BotBand",colorRed,styleLine);
> 
> 
> 
> 
> 
> Title=Name()+"...Percent of enclosure = "+WriteVal(percent,1)+" % 
based on "+"[ "+WriteVal(pds,1)+" ]"+" Periods"+"\n"+"Topband 
= "+WriteVal(topband,format=1.2)+"\n"+"Midline = " +WriteVal
(midline,format=1.2)+"\n"+"BotBand = " +WriteVal(botband,format=1.2)
+"\n"+"Todays Close = " +WriteVal(C,format=1.2);
> 
>   ----- Original Message ----- 
>   From: Rick Osborn 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   Sent: Saturday, September 20, 2003 10:53 AM
>   Subject: Re: [amibroker] Re: Adjustable Bollinger Bands
> 
> 
>   Dimitris
>   Yes - thank you very much.
>   I can't help but think, however, that there must be a 
mathematical formula that will automatically calculate the "actual" 
95% (or 90% - or 83% - or whatever) based on each stock's own 
particular price history.  
> 
>   But I can certainly work with this solution.  Thanks again
>   Rick
>     ----- Original Message ----- 
>     From: DIMITRIS TSOKAKIS 
>     To: amibroker@xxxxxxxxxxxxxxx 
>     Sent: Saturday, September 20, 2003 10:33 AM
>     Subject: [amibroker] Re: Adjustable Bollinger Bands
> 
> 
>     Rick,
>     Is it something like
>     http://groups.yahoo.com/group/amibroker/message/48289
>     ?
>     Dimitris Tsokakis
>     --- In amibroker@xxxxxxxxxxxxxxx, "Rick Osborn" <ricko@xxxx> 
wrote:
>     > Dimitris
>     > I was looking for bands that were a little smoother - and 
did not 
>     fluctuate as much as the BB's.
>     > 
>     > Perhaps I'm looking for a variation on the "x%" channel 
bands (i.e. 
>     topband = MA(n)*(1+x%) and botband = MA(n)*(1-x%).  Instead of 
a 
>     fixed percent (x% in this case) I am looking for a variable 
factor 
>     that captures "perc"% of the price range over the lookback 
period.  
>     It could be that the factor for the top band would differ from 
that 
>     of the bottom band.
>     > 
>     > I don't know if this is even possible but if it is, one 
might 
>     conclude that these bands would stop prices at the 
bands "perc" % of 
>     the time??
>     > Rick
>     >   ----- Original Message ----- 
>     >   From: DIMITRIS TSOKAKIS 
>     >   To: amibroker@xxxxxxxxxxxxxxx 
>     >   Sent: Friday, September 19, 2003 11:44 AM
>     >   Subject: [amibroker] Re: Adjustable Bollinger Bands
>     > 
>     > 
>     >   The moving average period is n.
>     >   Replace n=20 with n=21 to get the adjustment.
>     >   If you want envelope type other than BB, please specify 
the type 
>     you 
>     >   prefer and we shall check if the same procedure is 
possible.
>     >   Dimitris Tsokakis
>     >   --- In amibroker@xxxxxxxxxxxxxxx, "Rick Osborn" 
<ricko@xxxx> 
>     wrote:
>     >   > Dimitris
>     >   > Very interesting.
>     >   > Is there a way to calculate the same thing using a 21-
day 
>     moving 
>     >   average as the mid-point around which the adjustable bands 
move, 
>     >   rather than using BBands?
>     >   > Rick
>     >   > 
>     >   > ----- Original Message ----- 
>     >   >   From: Dimitris Tsokakis 
>     >   >   To: amibroker@xxxxxxxxxxxxxxx 
>     >   >   Sent: Friday, September 19, 2003 5:54 AM
>     >   >   Subject: [amibroker] Adjustable Bollinger Bands
>     >   > 
>     >   > 
>     >   > 
>     >   >   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 
>     >   >               ADVERTISEMENT
>     >   >              
>     >   >        
>     >   >        
>     >   > 
>     >   >   Send BUG REPORTS to bugs@xxxx
>     >   >   Send SUGGESTIONS to suggest@xxxx
>     >   >   -----------------------------------------
>     >   >   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 the Yahoo! 
Terms of 
>     >   Service.
>     > 
>     > 
>     >         Yahoo! Groups Sponsor 
>     >               ADVERTISEMENT
>     >              
>     >        
>     >        
>     > 
>     >   Send BUG REPORTS to bugs@xxxx
>     >   Send SUGGESTIONS to suggest@xxxx
>     >   -----------------------------------------
>     >   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 the Yahoo! Terms 
of 
>     Service.
> 
> 
> 
>     Send BUG REPORTS to bugs@xxxx
>     Send SUGGESTIONS to suggest@xxxx
>     -----------------------------------------
>     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 the Yahoo! Terms of 
Service. 
> 
> 
>         Yahoo! Groups Sponsor 
>               ADVERTISEMENT
>              
>        
>        
> 
> 
>   Send BUG REPORTS to bugs@xxxx
>   Send SUGGESTIONS to suggest@xxxx
>   -----------------------------------------
>   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 the Yahoo! Terms of 
Service. 
> 
> 
>   ---
>   Outgoing mail is certified Virus Free.
>   Checked by AVG anti-virus system (http://www.grisoft.com).
>   Version: 6.0.520 / Virus Database: 318 - Release Date: 9/18/2003


------------------------ Yahoo! Groups Sponsor ---------------------~-->
ReplayTV: CNet Ranked #1 over Tivo!
Instant Replay & Pause live TV.
Special Sale: 50% off!
http://us.click.yahoo.com/UUMW7B/.5qGAA/ySSFAA/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/