# Amibroker AFL: Step by Step Tutorial- Part 2

This is Part 2 of Amibroker AFL tutorial series. If you haven’t already gone through Part 1 of this series, please find it in the below link:-

Amibroker AFL: Step by Step Tutorial- Part 1

### Parameterized AFL code

```//------------------------------------------------------
//  Formula Name:    Parameterized AFL code
//------------------------------------------------------

_SECTION_BEGIN("Parameters");
Plot(Close,"Price",ParamColor("Color",colorBlue),styleLine);
_SECTION_END();

```

### Plotting simple EMA Indicator

```//------------------------------------------------------
//  Formula Name:    Simple EMA Indicator
//------------------------------------------------------

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

### Plotting parameterized EMA

```//------------------------------------------------------
//  Formula Name:    Parameterized EMA
//------------------------------------------------------

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

```

### Plotting a Heikin Ashi Chart

```//------------------------------------------------------
//  Formula Name:    Heikin Ashi Chart
//------------------------------------------------------

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

```

### Writing text to Commentary window

```//------------------------------------------------------
//  Formula Name:    Commentary
//------------------------------------------------------

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

```