Dear Friends,
I am very new on Amibroker and AFL. No software background too... I have searched on the internet and managed to write the below codes. This code is giving me the BUY/SELL & SHORT/COVER signals, but the execution is happening only at "CLOSE" price, not on the value where the signal gets generated. Also, I wish to display that signal value on the screen, but I don't know how to write code for the same. It is either giving me "C" or "O". How to get the exact value where the signal is generated.
Kindly help..
Regards,
Mahesh
_SECTION_BEGIN("HA");
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 ) );
barcolor = IIf(HaClose >= HaOpen,colorGreen,colorRed);
Plot( C, "Price", colorDefault, styleCandle );
Buy = ExRem(Haopen < Haclose , Haopen > Haclose) ;
Sell = ExRem(Haopen > Haclose , Haopen < Haclose) ;
Cover = ExRem(Haopen < Haclose , Haopen > Haclose) ;
Short = ExRem(Haopen > Haclose , Haopen < Haclose) ;
if (Buy[BarCount-1]==true)
{
PopupWindow("Buy Signal Initiated","Buy Signal",4, 1350, 150, 150,100);
Say("Attention, Buy Signal Initiated");
}
if (Sell[BarCount-1]==true)
{
PopupWindow("Sell Signal Initiated","Sell Signal",4, 1350, 150, 150,100);
Say("attention, Sell Signal Initiated");
}
//========================================================================
dist = 1.5*ATR(20);
distbuy=10;
distsell=25;
for( i = 0; i < BarCount; i++ )
{
if( Buy[i] ) PlotText( "@ " + O[ i ], i, L[ i ]-dist[i], colorLime );
if( Sell[i] ) PlotText( "@ " + O[ i ], i, L[ i ]+dist[i], colorYellow );
}
//========================================================================
/* Plot Buy and Sell Signal Arrows */
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
_SECTION_END();