Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/27/2006(UTC) Posts: 135
|
Below is a code for zigzag validity
How to make the code plot 1 representing valid to the next zigzag turn?
The current code plots 0 with price fall below x% even previously price has move x% and the current zigzag is valid
PerCha:=Input("Percent",0.1,100,10); Plot:=Input("Result, 0=Validity, 1=Last Change (Th=-1, Pk=1)",0,1,0); Zg:=Zig(C,PerCha,%); CurZgPiv:=ValueWhen(1,( Zg > Ref(Zg,-1) AND Ref(Zg,-1) < Ref(Zg,-2) ) OR ( Zg < Ref(Zg,-1) AND Ref(Zg,-1) > Ref(Zg,-2) ),Ref(Zg,-1) ); PerChaDiff:=Abs( ( C - CurZgPiv ) / CurZgPiv * 100 );
SD:=( Zg > Ref(Zg,-1) AND Ref(Zg,-1) > Ref(Zg,-2) ) OR (Zg < Ref(Zg,-1) AND Ref(Zg,-1) < Ref(Zg,-2) ); Valid:=If(PerChaDiff >= Percha ,1,0); Validity:=If(Alert(Valid,2) AND SD,1,Valid); CurPiv:=If( Zg > Ref(Zg,-1),1,-1); If(Plot = 0,Validity,CurPiv);
|