----- 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();