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

Re: [amibroker] Better Bollinger Bands



PureBytes Links

Trading Reference Links

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





Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___