# Need code for modified heiken ashi formula

sir i have formula for modified heiken ashi and i need the code for amibroker . plz sir kindly reply

my formula for modied heiken ashi is .

for 1st candle :

haopen1 = open

haclose1 = (haopen1+high+low+2*close)/5

for 2nd candle :

haopen2 = (haopen1+haclose1)/2

haclose2 = (haopen2+high+low+2*close)/5

for 3rd candle :

haopen3 =(haopen2+haclose2)/2

haclose3 = (haopen3+high+low+2*close)/5

for 4th candle :

haopen4 = (haopen3+haclose3)/2

haclose4 = (haopen4+high+low+2*close)/5

for 5th candle :

haopen5 = (haopen4+haclose4)/2

haclose5 = (haopen5+high+low+2*close)/5

hahigh5 = (haopen1+haopen2+haopen3+haopen4+haopen5)/5

halow5 = (haclose1+haclose2+haclose3+haclose4+haclose5)/5

for 6th candle :

haopen6= (haopen5+haclose5)/2

haclose6 = (haopen6+high +low+2*close)/5

hahigh6 = (haopen2+haopen3+haopen4+haopen5+haopen6)/5

halow6 = (haclose2+haclose3+haclose3+haclose4+haclose5+haclose6)/5

from 7th candle so on …

( all open ,high ,low ,close prices are reference to candles of candlestick pattern chart)

the below is the sample AFL code for heiken ashi , you can modify the candle values accordingly

```_SECTION_BEGIN("heiken");
SetChartOptions(0,chartShowArrows | chartShowDates);

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 ) );
xDiff = (HaHigh - Halow) * 10000;
barcolor = IIf(HaClose >= HaOpen,colorBrightGreen,colorRed);
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle );
_SECTION_END();```

as per above condition it is possible but,little bit complex you can contact some AFL expert