//AFL by Kamalesh Langote. Website: http://www.vfmdirect.com/kplswing
//Recommended indicator value is 20. Lower values will generate more trades and whipsaws.
no=Param( "Swing", 20, 1, 55 );
res=HHV(H,no);
sup=LLV(L,no);
tsl=IIf(ValueWhen(IIf(C>Ref(res,-1),1,IIf(CRef(res,-1),1,IIf(C
Plot(tsl, _DEFAULT_NAME(), colorBlack, styleStaircase);
Buy=Cross(C,tsl);
Sell=Cross(tsl,C);
shape=Buy*shapeUpArrow + Sell*shapeDownArrow;
PlotShapes(shape,IIf(Buy,colorBlack,colorBlack),0,IIf(Buy,Low,High));