nasdaqtrader,
how about this:
buy order:
lb:=TroughBars(1,L,.1);
hb:=PeakBars(1,H,.1);
plot:=Zig(If(lb<hb, L, H ),1,%);
new:=PeakBars(1,plot,1)=0 OR TroughBars(1,plot,1)=0;
setup:=If(new,Cross(H, Peak(2,plot,1)),Cross(H, Peak(1,plot,1))) and H>Mov(C,20,E) ;
H>(Valuewhen(1,setup,H)+0.1) and BarsSince(setup)<=2;
order type - stop:
lb:=TroughBars(1,L,.1);
hb:=PeakBars(1,H,.1);
plot:=Zig(If(lb<hb, L, H ),1,%);
new:=PeakBars(1,plot,1)=0 OR TroughBars(1,plot,1)=0;
setup:=If(new,Cross(H, Peak(2,plot,1)),Cross(H, Peak(1,plot,1))) and H>Mov(C,20,E) ;
max(O,Valuewhen(1,setup,H)+0.1)
Sell order:
lb:=TroughBars(1,L,.1);
hb:=PeakBars(1,H,.1);
plot:=Zig(If(lb<hb, L, H ),1,%);
new:=PeakBars(1,plot,1)=0 OR TroughBars(1,plot,1)=0;
upF:=H<Ref(H,-1) AND Ref(H,-1)>Ref(H,-2);
downF:=L>Ref(L,-1) AND Ref(L,-1)<Ref(L,-2);
F1:=ValueWhen(1,upF,Ref(H,-1));
F2:=ValueWhen(1,downF,Ref(L,-1));
setup:=If(new,Cross(Trough(2,plot,1),L),Cross(Trough(1,plot,1),L)) ;
ref(setup,-1) or L<F2
order type - stop:
lb:=TroughBars(1,L,.1);
hb:=PeakBars(1,H,.1);
plot:=Zig(If(lb<hb, L, H ),1,%);
new:=PeakBars(1,plot,1)=0 OR TroughBars(1,plot,1)=0;
upF:=H<Ref(H,-1) AND Ref(H,-1)>Ref(H,-2);
downF:=L>Ref(L,-1) AND Ref(L,-1)<Ref(L,-2);
F1:=ValueWhen(1,upF,Ref(H,-1));
F2:=ValueWhen(1,downF,Ref(L,-1));
setup:=If(new,Cross(Trough(2,plot,1),L),Cross(Trough(1,plot,1),L)) ;
If(ref(setup,-1),O,min(O,F2))
For shorts just modify as appropriate.
Give it a try and let me know if it is accurate enough (had no time to test it at length). Some code here and there is redundant but is included so as to make adaptation to shorts easier. Any suggestions on possible improvements would be appreciated.
Regards.