Skip to main content

Bollinger Band Trend for Amibroker (AFL)

hoductoan123qn@gmail.com about 4 years ago Amibroker (AFL)

  • Rating:
    5 / 5 (Votes 1)
  • Tags:
    amibroker

This indicator is used to determine the trend of BB, the increase or decrease of BB when combined with the trend of the price will give good signals for entering into positions.

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("Bollinger Band Trend Filter");

ST_TR=EMA(C,5);
MID_TR=EMA(C,10);
INT_TR=EMA(C,15);
LNG_TR=EMA(C,20);

ST_VAL = IIf(ST_TR > BBandTop(C,15,0.5),1, IIf(ST_TR<BBandTop(C,15,0.5) AND ST_TR>BBandBot(C,15,0.5),0,-1));
MID_VAL = IIf(MID_TR > BBandTop(C,20,0.5),1, IIf(MID_TR<BBandTop(C,20,0.5) AND MID_TR>BBandBot(C,20,0.5),0,-1));
Int_VAL = IIf(INT_TR > BBandTop(C,30,0.5),1, IIf(INT_TR<BBandTop(C,30,0.5) AND INT_TR>BBandBot(C,30,0.5),0,-1));
LNG_VAL = IIf(LNG_TR > BBandTop(C,50,0.5),1, IIf(LNG_TR<BBandTop(C,50,0.5) AND LNG_TR>BBandBot(C,50,0.5),0,-1));

ST_TF = ST_VAL*10;
MID_TF = MID_VAL*20;
INT_TF = Int_VAL*30;
LNG_TF = LNG_VAL*40;


TF= ST_TF + MID_TF + INT_TF + LNG_TF;

// TREND FILTER RANKING
TFRNK = 
IIf(TF>= 50,3,
IIf(TF<50 AND TF>25,2,
IIf(TF<25 AND TF>=0,1,
IIf(TF<0 AND TF>= -25,-1,
IIf(TF<-25 AND TF>=-50,-2,
IIf(TF<-50,-3,0))))));

TFCLR = 
IIf(TFRNK==3,ColorRGB(0,255,0),
IIf(TFRNK==2,colorGreen,
IIf(TFRNK==1,colorOrange,
IIf(TFRNK==-1,ColorRGB(252,70,0),
IIf(TFRNK==-2,ColorRGB(255,80,80),
IIf(TFRNK==-3,ColorRGB(217,0,0),colorGrey40))))));

// PRICE PLOT

Plot(TFRNK,"BB TREND FILTER",TFCLR ,styleThick);
Plot (0,"",colorGrey50,styleLine);
Plot (-.5,"",colorGrey50,styleDashed);
Plot (0.5,"",colorGrey50,styleDashed);


_SECTION_BEGIN("EMA1");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 300, 1, 10 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
_SECTION_END();

2 comments

about 4 years ago

can you help for one afl

my buy is when ema 8 cross 18 ema and rsi above 60.this afl already made with all your support.but for selling i need taget of 15% and stoploss 10%.

2. Suren
over 3 years ago

Can someone explain on how to use this AFL?

Advance Thanks,

Leave Comment

Please login here to leave a comment.