//------------------------------------------------------
// Formula Name: Parameterized AFL code
// Website: https://zerobrokerageclub.com/
//------------------------------------------------------
_SECTION_BEGIN("Parameters");
Plot(Close,"Price",ParamColor("Color",colorBlue),styleLine);
_SECTION_END();
Recommended Reading: Mastering Amibroker – A Comprehensive Guide
Crafting a Simple EMA Indicator
//------------------------------------------------------
// Formula Name: Parameterized AFL code
// Website: https://zerobrokerageclub.com/
//------------------------------------------------------
_SECTION_BEGIN("Simple EMA Indicator");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} – {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot(Close,"Price",color=colorBlue,style=styleCandle);
Plot(EMA(C,50),"EMA50",ParamColor("EMAColor",colorBlue));
_SECTION_END();
Creating a Parameterized EMA Chart
//------------------------------------------------------
// Formula Name: Parameterized AFL code
// Website: https://zerobrokerageclub.com/
//------------------------------------------------------
_SECTION_BEGIN("Parameterized EMA Indicator");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} – {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot(Close,"Price",color=colorBlue,style=styleCandle);
EMAPeriod=Param("EMAPeriod",50,1,200,1);
Plot(EMA(C,EMAPeriod),"EMA",ParamColor("EMAColor",colorBlue));
_SECTION_END();
Designing a Heikin Ashi Chart in AFL
//------------------------------------------------------
// Formula Name: Parameterized AFL code
// Website: https://zerobrokerageclub.com/
//------------------------------------------------------
_SECTION_BEGIN("Heikin Ashi Chart");
SetChartOptions(0,chartShowArrows | chartShowDates);
_N(Title = StrFormat("{{NAME}} – {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
HaClose = (O + H + L + C)/4;
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 );
HaHigh = Max( H, Max( HaClose, HaOpen ) );
HaLow = Min( L, Min( HaClose, HaOpen ) );
barcolor = IIf(HaClose >= HaOpen,colorGreen,colorRed);
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "HeikinAshi", barcolor, styleCandle );
_SECTION_END();
Adding Commentary to Your Charts
//------------------------------------------------------
// Formula Name: Parameterized AFL code
// Website: https://zerobrokerageclub.com/
//------------------------------------------------------
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} – {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", colorDefault,styleCandle );
_SECTION_END();
_SECTION_BEGIN("Volume");
Plot( Volume, "Volume", color=colorGrey40, ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick, maskHistogram ) );
writeif( Volume > ma(Volume,5), "The volume is greater than 5 days average. Indicates a good buying opportunity","None");
_SECTION_END();
2 Comments