Algo script coding

How to code heiken ashi in following scenario I just want to buy if close of current heiken achi candle is more than close of last candle … At this point of time I don’t need exit long script, just a buy signal…

Please find the Amibroker AFL code which plots buy and sell for your condition.

Regards

Vivith

_SECTION_BEGIN("Heikin_Ashi");
//-------------------------------------------------------------------------------------------
//
//  Formula Name:    HeiKin Ashi Candlesticks
//  Author/Uploader: Neotrade Analytics Pvt Ltd 
//  E-mail:          [email protected]
//  Website          www.neotradeanalytics.com
//
//This is an attempt to provide a basic system's in AFL. The system is purely imaginary
//AND NOT provided as one that would make money. This is just to provide a guide to learners
//on the common components of writing AFL.
//
//-------------------------Summary of AFL-----------------------------------------------------
//Plot Heiken Ashi Candlesticks in Amibroker
//---------------------------------------------------------------------------------------------

SetChartOptions(0,chartShowArrows | chartShowDates);
//Calculate HA Candle Close value
HaClose =EMA((O+H+L+C)/4,3); 
BarPeriod = 50; 

//Calculate HA Candle Open value
HaOpen = AMA( Ref( HaClose, -1 ), 0.5 ); 

//Calculate HA Candle High value
HaHigh = Max( H, Max( HaClose, HaOpen ) ); 

//Calculate HA Candle Low value
HaLow = Min( L, Min( HaClose, HaOpen ) ); 
//Buy = Ref(HaClose,-1) > Ref(HaHigh,-2);
 
//Sell = Ref(HaClose,-1) < Ref(HaLow,-2);

LastHigh = HHV(HaHigh, BarPeriod);
LastLow = LLV(HaLow,BarPeriod);

Buy =  HaClose > Ref(HaClose, - 1);
Sell = HaClose < Ref(HaClose, -1);
 
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);

Short = Sell;
Cover = Buy;
 
PlotShapes(shapeUpArrow*Buy,colorGreen, 0, L, Offset=-45);
 
PlotShapes(shapeSmallDownTriangle*Sell,colorred, 0, L, Offset=-45); barcolor = IIf(HaClose >= HaOpen,colorGreen,colorRed);
//Plot the values in amibroker charts
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle );

barcolor = IIf(HaClose >= HaOpen,colorGreen,colorRed);
//Plot the values in amibroker charts
PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "", barcolor, styleCandle );

_SECTION_END();