Skip to main content

Trailing Stoploss for Amibroker (AFL)

mdfno almost 16 years ago Amibroker (AFL)

  • Rating:
    5 / 5 (Votes 1)
  • Tags:
    amibroker, stop loss

Guards profit when trend reverses the direction, it should to overlayed on price chart.

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("Stoploss");
no=20;
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
supres=IIf(avn==1,sup,res);

color=IIf(avn==1,colorPaleGreen,colorOrange);
Plot(supres,"Stoploss",color,styleStaircase|styleThick|styleNoTitle);
_SECTION_END();

1 comments

Leave Comment

Please login here to leave a comment.