barssince , state syntax in AFL
The following AFL code is to avoid multiple entries .May be useful for future reference.
state1=IIf(BarsSince(BUY1)<BarsSince(SELL1),1,0);
s1=state1>Ref(state1,-1);
ss1=state1<Ref(state1,-1);
sss1=state1==Ref(state1,-1);
col=IIf(state1 == 1 ,51,IIf(state1 ==0,4,1));
Plot(C,"",Col,128);
PlotShapes( shapeUpArrow * s1 ,6,0,L);
PlotShapes( shapeDownArrow *ss1 ,4,0,H);
state2=IIf(BarsSince(BUY2)<BarsSince(SELL2),1,0);
s2=state2>Ref(state2,-1);
ss2=state2<Ref(state2,-1);
sss2=state2==Ref(state2,-1);
col=IIf(state2 == 1 ,51,IIf(state2 ==0,4,1));
Plot(C,"",Col,128);
PlotShapes( shapeUpArrow * s2 ,6,0,L);
PlotShapes( shapeDownArrow *ss2 ,4,0,H);
The following AFL code is to avoid multiple entries .May be useful for future reference.
state1=IIf(BarsSince(BUY1)<BarsSince(SELL1),1,0);
s1=state1>Ref(state1,-1);
ss1=state1<Ref(state1,-1);
sss1=state1==Ref(state1,-1);
col=IIf(state1 == 1 ,51,IIf(state1 ==0,4,1));
Plot(C,"",Col,128);
PlotShapes( shapeUpArrow * s1 ,6,0,L);
PlotShapes( shapeDownArrow *ss1 ,4,0,H);
state2=IIf(BarsSince(BUY2)<BarsSince(SELL2),1,0);
s2=state2>Ref(state2,-1);
ss2=state2<Ref(state2,-1);
sss2=state2==Ref(state2,-1);
col=IIf(state2 == 1 ,51,IIf(state2 ==0,4,1));
Plot(C,"",Col,128);
PlotShapes( shapeUpArrow * s2 ,6,0,L);
PlotShapes( shapeDownArrow *ss2 ,4,0,H);