.

Bollinger Band Overbought Oversold Line - Amibroker AFL Code

Click Image To Enlarge. Please Rate And Comment.

Bollinger Band Overbought Oversold Line

_SECTION_BEGIN("_BollingerLine Indicator");

 GraphXSpace=7;

 periods = Optimize("periods ",Param("periods ",20,1,48,1),1,48,1);
 width = Optimize("width ",Param("width ",2,0.1,10,0.1),0.1,10,0.1);

 C1 = C - BBandBot( Close, periods, width) ;
 C2 = BBandTop (Close,periods,width) - BBandBot( Close, periods, width);

 R = (C1 / C2)*100;
 RS = (AMA( C1, 0.5 ) / AMA( C2, 0.5 ))*100; //smooth

 uptrend = r > Ref(r,-1);
 downtrend = r < Ref(r,-1);

 uptrendS = rs > Ref(rs,-1);
 downtrendS = rs < Ref(rs,-1);

 BS = ParamToggle("smooth","No|Yes",1);
 BN = ParamToggle("normal","No|Yes",0);

 if (BS) Plot( RS , " smooth ", IIf(( uptrendS ), colorGreen, colorRed ));
 if (BS) Plot ( 1, "", IIf( uptrendS , colorGreen, IIf( downtrendS , colorRed, colorPink )), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

 if (BN) Plot( R , " normal ", IIf(( uptrend ), colorGreen, colorRed ));
 if (BN) Plot ( 2, "", IIf( uptrend, colorGreen, IIf( downtrend, colorRed, colorPink )), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

 _SECTION_END();

 _SECTION_BEGIN("Bollinger Bands");
 P = rs ;//ParamField("Price field",-1);
 Periods = Param("Periods", 15, 2, 100, 1 );
 Width = Param("Width", 2, 0, 10, 0.05 );
 Color = ParamColor("Color", colorLightGrey );
 Style = ParamStyle("Style", styleLine | styleNoLabel ) | styleNoLabel;
 bbt = BBandTop( P, Periods, Width );
 bbb = BBandBot( P, Periods, Width );
 Plot( bbt , "BBTop" + _PARAM_VALUES(), colorBlack, Style ); 
 Plot( bbb , "BBBot" + _PARAM_VALUES(), colorBlack, Style ); 
 PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( Color, colorWhite, 0.9 ), styleNoLabel | styleCloud | styleNoRescale, Null, Null, Null, -1 );
 _SECTION_END();

 bbm = (bbb + bbt) / 2; // middle bollingerbands
 f= Optimize("colored bandsize factor",Param("colored bandsize factor",7,1,100,1),1,100,1);

 bbmf = (bbm / 100) * f;

 bwup = (bbt - bbmf);
 bwlo = (bbb + bbmf);

 PlotOHLC (bbb ,bbb ,bwlo ,bwlo ,"lowercloud",colorPink,styleCloud,0,0,0);
 PlotOHLC (bbt ,bbt ,bwup ,bwup ,"uppercloud",colorBrightGreen,styleCloud,0,0,0 );
 Plot( bbm , "BBMiddle" + _PARAM_VALUES(), colorPink, styleDashed );

 b1= C > O AND L>Ref(L,-1) AND (Ref(L,-1) > Ref(L,-2) OR (C>Ref(O,-1) AND O<Ref(H,-1)));
 b2= rs > Ref(rs,-1) AND rs < bwup AND Ref(rs,-1) < Ref(bwup,-1);

 Buy = b1 AND b2;
Previous Post Next Post