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

[amibroker] Re: Better Bollinger Bands



PureBytes Links

Trading Reference Links

What do I need to get a "middle Line"? Thanks

Dick H

--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@xxx> wrote:
>
> Hello,
> 
> Replace lines like that:
> 
> mt = alpha*C+(1-alpha)*(if(Cum(1)<pds,C,PREV));
> 
> with AFL equivalent (simpler):
> 
> mt = AMA( C, alpha );
> 
> Any other statement involving PREV the same way.
> 
> Final result:
> 
> pds=Param("Periods",20,2,200); 
> sd=Param("Standard Deviations",2, 0.01,10); 
> alpha=2/(pds+1); 
> mt=AMA( C, alpha ); 
> ut=AMA( mt, alpha ); 
> dt=((2-alpha)*mt-ut)/(1-alpha); 
> mt2=AMA(abs(C-dt), alpha ); 
> ut2=AMA(mt2,alpha ); 
> dt2=((2-alpha)*mt2-ut2)/(1-alpha); 
> but=dt+sd*dt2; 
> blt=dt-sd*dt2; 
> 
> Plot( C, "Price", colorBlack, styleCandle ); 
> Plot( but, "Upper band", colorRed ); 
> Plot( blt, "Lower band", colorRed ); 
> 
> 
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
>   ----- Original Message ----- 
>   From: mohany1@xxx 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   Cc: amibroker@xxxxxxxxxxxxxxx ; amibroker@xxxxxxxxxxxxxxx 
>   Sent: Sunday, February 15, 2009 3:37 AM
>   Subject: [amibroker] Better Bollinger Bands
> 
> 
>   Someone was asking for this afl. I got around to translating. Enjoy.
> 
> 
>   Now, if only someone can teach me , really how to make money !!!
> 
> 
>   /*
>   Better Bollinger Bands I
> 
> 
>   pds:=Input("Periods",2,200,20);
>   sd:=Input("Standard Deviations",.01,10,2);
>   alpha:=2/(pds+1);
>   mt:=alpha*C+(1-alpha)*(if(Cum(1)<pds,C,PREV));
>   ut:=alpha*mt+(1-alpha)*(if(Cum(1)<pds,C,PREV));
>   dt:=((2-alpha)*mt-ut)/(1-alpha);
>   mt2:=alpha*abs(C-dt)+(1-alpha)*PREV;
>   ut2:=alpha*mt2+(1-alpha)*PREV;
>   dt2:=((2-alpha)*mt2-ut2)/(1-alpha);
>   but:=dt+sd*dt2;
>   blt:=dt-sd*dt2;
>   dt;
>   but;
>   blt
> 
> 
>   //------------  easy language -----------
> 
> 
>   inputs:
>   lookback(20),
>   mult(2);
> 
> 
>   vars:
>   alpha(0),
>   mt(0),
>   ut(0),
>   dt(0),
>   mt2(0),
>   ut2(0),
>   dt2(0),
>   but(0),
>   blt(0);
> 
> 
>   alpha = 2 / (lookback + 1);
>   mt = alpha * close + (1 - alpha) * mt;
>   ut = alpha * mt + (1 - alpha) * ut;
>   dt = ((2 - alpha) * mt - ut) / (1 - alpha);
>   mt2 = alpha * absvalue(close - dt) + (1 - alpha) * mt2;
>   ut2 = alpha * mt2 + (1 - alpha) * ut2;
>   dt2 = ((2 - alpha) * mt2 - ut2) / (1 - alpha);
>   but = dt + mult * dt2;
>   blt = dt - mult * dt2;
>   plot1(dt,"CenterB");
>   plot2(but,"UpperB");
>   plot3(blt,"LowerB");
>   */
> 
> 
>   _SECTION_BEGIN("Better Bollinger Bands");
>   pds = Param("Periods",2,1,200,1);
>   SD = Param("sd",3,0.01,5,0.01);
>   ALPHA = 2/(PDS+1);
>   mt = AMA(C, alpha);
>   ut = AMA(mt, alpha);
>   dt = ((2 - alpha) * mt - ut) / (1 - alpha);
>   //mt2 = alpha * absvalue(Close - dt) + (1 - alpha) * mt2;
>   mt2 = AMA(abs(C - dt), alpha);
> 
> 
>   ut2 = AMA( mt2 , alpha) ;
>   dt2 = ((2 - alpha) * mt2 - ut2) / (1 - alpha);
> 
> 
>   but = dt + sd * dt2;
>   blt = dt - sd * dt2;
> 
> 
>   Plot(but,"Upper Band", colorRed, styleLine);
>   Plot(dt,"Cente Band", colorBlue, styleLine);
>   Plot(blt,"Lower Band", colorBrightGreen, styleLine);
> 
> 
>   _SECTION_END();
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

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