Join our facebook group for Amibroker afl code discussion https://www.facebook.com/groups/603980776889348

Bollinger Band EMA Perfect Combination

Bollinger Band EMA Perfect Combination
Bollinger Band EMA Perfect Combination

//www.aflcode.com
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorYellow ), styleBar, styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
{
ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));
}
_SECTION_END();

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

_SECTION_BEGIN("BB-EMA");
Tp=(H+L+C)/3;
Per = Param("EMA Periods", 20, 2, 200, 1);
stper=Param("StDev Period",20,10,30,1);
w=Param("Width",2,0.5,4,0.5);
BBup=EMA(tp,per)+w*StDev(C,stper);
BBdn=EMA(tp,per)-w*StDev(C,stper);
BB_Mid=EMA(((BBup+BBdn)/2),5);

Plot (bbup,"BB-UP",ParamColor( "Color", colorLightGrey ),styleLine);
Plot (bbdn,"BB-DN",ParamColor( "Color", colorLightGrey ),styleLine);
Plot (bb_mid,"BB_Mid",ParamColor( "Color", colorBlue ),styleLine);
PlotOHLC(BBup,BBup,BBdn,BBdn,"BB-EMA", ParamColor("color",colorDarkOliveGreen), styleCloud);


_SECTION_END();
Previous
Next Post »