Help in afl coding: Entry above high / below low

#1
Hi,

I am trying to take a trade after:
1. Buy signal comes as per my indicator below
2. High (on which the buy signal came) + 5 points to validate the signal
and vice versa for Short.

I have been trying to achieve this with the Buyprice and sellprice but no luck so far. I know there must be a straight forward way to do this.
Can the seniors please guide me to achieve this?

This is one of the indicators on which i want to apply this:

SetBarsRequired(100000,0);
GraphXSpace = 15;
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkColor(ParamColor("bkcolor",ColorRGB(0,0, 0)));

GfxSetBkMode(0);
GfxSetOverlayMode(1);

SetBarFillColor(IIf(C>O,ParamColor("Candle UP Color", colorGreen),IIf(C<=O,ParamColor("Candle Down Color", colorRed),colorLightGrey)));

Plot(C,"nPrice",IIf(C>O,ParamColor("Wick UP Color", colorDarkGreen),IIf(C<=O,ParamColor("Wick Down Color", colorDarkRed),colorLightGrey)),64,0,0,0,0);

SetPositionSize(100,spsShares);

//parameters

P = ParamField("Price field",-1);
per1 = Param("EMA1",2,1,20,1);
per2 = Param("EMA2",36,1,50,1);

Buy = Cross(EMA(C,per1),EMA(C,per2));
Sell= Cross(EMA(C,per2),EMA(C,per1)) ;

Buy=ExRem(Buy,Sell) ;
Sell=ExRem(Sell,Buy);

Short=Sell ;
Cover=Buy ;


Plot( EMA( P, per1 ), "EMA1", ParamColor( "Color1", colorCycle ), ParamStyle("Style") );
Plot( EMA( P, per2 ), "EMA2", ParamColor( "Color2", colorCycle ), ParamStyle("Style") );

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


Any help or guidance will be much appreciated.

Thanks
A
 

Similar threads