n= Param("No.of Bars",-1,-1,100,1);
m=Param("No of Earlier Bars",-1,-1,100,1);
Buy = (H > Ref(H,n)) AND (Ref(H,n) > Ref(H,m)) AND (L > Ref(L,n)) AND (Ref(L,n) > Ref(L,m));
Sell = (H < Ref(H,n)) AND (Ref(H,n) < Ref(H,m)) AND (L < Ref(L,n)) AND (Ref(L,n) < Ref(L,m));
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
PlotShapes(IIf(Buy, shapeUpArrow,shapeNone),colorGreen,0,L,-15);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,H,-15);
Plot(C,"Close",colorDefault,64);
Filter=Buy OR Sell ;
AddColumn(C,"Close",1.2);
AddColumn(Buy,"Buy Triggered",1);
AddColumn(Sell,"Sell Triggered",1);