Please provide Amibroker AFL for the strategy

#1
Can any one please provide the amibroker AFL for the below strategy.

Entry for long: When price of a scrip reaches certain points above immediate pivot low (Eg:10, 20 or 50.... points above pivot low). No. of points to be specified through Parameter.

Trailing Stop Loss for long: When price of a scrip reaches certain points down from long entry (Eg:10, 20 or 50... points down from long entry and trailed). No. of points to be specified through Parameter.

Entry for Short: When price of a scrip reaches certain points below immediate pivot high (Eg:10, 20 or 50... points below pivot high). No. of points to be specified through Parameter.

Trailing Stop Loss for Short: When price of a scrip reaches certain points above short entry (Eg:10, 20 or 50... points above short entry and trailed). No. of points to be specified through Parameter.

Thanks
 
#2
Some how I have managed to get the pivot points in the chart by modifying a bit to the below afl code which was shared earlier by someone in the forum.
As I don't know coding, could not succeed in getting entry and exit signals for long and short. :confused:

Please someone help me to code the strategy mentioned earlier.

Thanks

//======== Plot Shapes ========
procedure pshp(x,y,shp,co,shf) {
x=SelectedValue(x); y=SelectedValue(y);
PlotShapes(IIf(BarIndex()==x,shp,0),co,0,y,shf); }
//======== Fractal Peak Trough ========
x= BarIndex();
function pkID(nb){ p=H==HHV(H,2*nb)AND Ref(HHV(H,nb),nb)<H;
return p AND LastValue(x)-ValueWhen(p,x)>nb; }
function trID(nb){ t=L==LLV(L,2*nb)AND Ref(LLV(L,nb),nb)>L;
return t AND LastValue(x)-ValueWhen(t,x)>nb; }
//=============================
_SECTION_BEGIN("Select Pivots");
//=============================
//SetBarsRequired(sbrAll,sbrAll);
nn= Param("Fractal Minimum",2,2,150,0);
plf= ParamList("Pivots","Fractals",0);
//==================
x= BarIndex();
Lx=LastValue(x);
//==================
pk= pkID(nn); tr= trID(nn);
tx1= ValueWhen(tr,x,1); px2= ValueWhen(pk,x,2);
pk= IIf(pk,IIf(px2<tx1,pk,IIf(ValueWhen(pk,H,2)>H,False,pk)),pk);
px1= ValueWhen(pk,x,1); tx2= ValueWhen(tr,x,2);
tr= IIf(tr,IIf(tx2<px1,tr,IIf(ValueWhen(tr,L,2)<L,False,tr)),tr);
px0= ValueWhen(pk,x,0); tx0= ValueWhen(tr,x,0);
py0= ValueWhen(pk,H,0); ty0= ValueWhen(tr,L,0);
pk= IIf(pk AND px0>x,IIf(px0<tx0,IIf(py0>=H,False,pk),pk),pk);
tr= IIf(tr AND tx0>x,IIf(tx0<px0,IIf(ty0<=L,False,tr),tr),tr);
//===================
px= BarsSince(pk==1); tx= BarsSince(tr==1);
sup= SelectedValue(px) > SelectedValue(tx);
res= SelectedValue(tx)>= SelectedValue(px);
shp=shapeSmallCircle;
col= IIf(pk==1,42,IIf(tr==1,10,IIf(px>tx,19,IIf(tx>px,24,29))));
if(plf=="Ribbon" OR plf=="Both")Plot(2.25,"F
Swing",col,styleOwnScale|styleArea|4096,-1,100);
if(plf=="Fractals" OR plf=="Both"){PlotShapes(shp*pk,42,0,H,5);
PlotShapes(shp*tr,10,0,L,-5);}
//===================
yr1= ValueWhen(pk,H,1); xr1= ValueWhen(pk,x,1);
yr2= ValueWhen(pk,H,2); xr2= ValueWhen(pk,x,2);
yr3= ValueWhen(pk,H,3); xr3= ValueWhen(pk,x,3);
ys1= ValueWhen(tr,L,1); xs1= ValueWhen(tr,x,1);
ys2= ValueWhen(tr,L,2); xs2= ValueWhen(tr,x,2);
ys3= ValueWhen(tr,L,3); xs3= ValueWhen(tr,x,3);