Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/29/2004(UTC) Posts: 1,394 Location: Glastonbury, CT
Was thanked: 2 time(s) in 2 post(s)
|
{ZigZag validity engine by Spyros Raftopoulos} {additional code by Jose Silva} {1=ZigZag valid, 0=ZigZag invalid}
perc:=Input("ZigZag percent",.1,100,5); plot:=Input("plot: signals=1, % of valid signals=2, ZigZag=3",1,3, 1); x:=Input("use Open=1 High=2 Low=3 Close=4 Volume=5 P=6",1,6,4);
x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,V,If(x=6,P,C))))); z:=Zig(x,perc,%); z1:=Ref(z,-1); z2:=Ref(z,-2); last:=ValueWhen(1,z>z1 AND z1<z2 OR z<z1 AND z1>z2,z1); pc:=Abs((x-last)*100/last); SD:=z>z1 AND z1>z2 OR z<z1 AND z1<z2; res:=pc>=perc; valid:=If(Alert(res,2) AND SD,1,res); validper:=Cum(valid)/Cum(valid>-1)*100;
If(plot=3,z,If(plot=2,validper,valid))
|