Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/27/2006(UTC) Posts: 135
|
The troughbar measure the number of bars of the zigzag and plot the number of bars on turning points of the zigzag. How to plot the number of bars on the bar the zigzag is VALID rather than on the turning point?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
What do you mean by valid?
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/27/2006(UTC) Posts: 135
|
valid referring to close price has move the minimum amount used on the zigzag and zigzag is valid using 2% zigzag would require the closing price to to reverse 2% to be valid below is the code for zigzag valid perc:=Input("Percent",0.2,100,10);
Z:=Zig(CLOSE,perc,%);
last:=ValueWhen(1,( Z > Ref(Z,-1) AND Ref(Z,-1) < Ref(Z,-2) )
OR
( Z < Ref(Z,-1) AND Ref(Z,-1) > Ref(Z,-2) ),
Ref(Z,-1));
pc:=(CLOSE-last) * 100 / last;
pc:= Abs(pc);
SD:=(z>Ref(z,-1) AND Ref(z,-1)>Ref(z,-2)) OR (z<Ref(z,-1) AND Ref(z,-
1)<Ref(z,-2));
res:=If(pc>=perc ,1,0);
If(Alert(res,2) AND SD,1,res) but how to plot the troughbars on the bar with closing price move minimum of 2% valid
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
Will adding the following code on to the end of your function: work:
perc:=Input("Percent",0.2,100,10); Z:=Zig(CLOSE,perc,%); last:=ValueWhen(1,( Z > Ref(Z,-1) AND Ref(Z,-1) < Ref(Z,-2) ) OR ( Z < Ref(Z,-1) AND Ref(Z,-1) > Ref(Z,-2) ), Ref(Z,-1)); pc:=(CLOSE-last) * 100 / last; pc:= Abs(pc);
SD:=(z>Ref(z,-1) AND Ref(z,-1)>Ref(z,-2)) OR (z<Ref(z,-1) AND Ref(z,- 1)<Ref(z,-2));
res:=If(pc>=perc ,1,0); a1:=If(Alert(res,2) AND SD,1,res); {---------------------------} a2:=(a1=1)*(Ref(a1,-1)=0); a3:=BarsSince(a2=1); a3
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/27/2006(UTC) Posts: 135
|
The code has some errors
1) the code calculate number of bars from valid zigzag to another valid zigzag and not from low to low zigzag
2) Reset to zero while zigzag is on current swing should reset only zigzag turn direction
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
How about this:
perc:=Input("Percent",0.2,100,10);
a1:=Zig(CLOSE,perc,%); a2:=(a1>Ref(a1,-1))*(Ref(a1,-1)<Ref(a1,-2)); a3:=BarsSince(a2=1); a3
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/27/2006(UTC) Posts: 135
|
johnl you don't understand what is the suggestion or your coding require more tweaking
don't anyhow provide code which you are not sure
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users Joined: 11/7/2005(UTC) Posts: 602
|
Well, Flexi.... If you plot my function against the ZigZag function, my function gives the bars count from one trough to the next per your request #1. Since you seem to be disgruntled with my posts I will refrain from answering your posts in the future.
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Unverified Users Joined: 7/12/2007(UTC) Posts: 134 Location: Perth Western Australia
|
Flexi, are you for real man, just how rude can you be!
You have posted a request for help on the forum without attaching either a chart indicating exactly what you are trying to achieve
or your attempt at coding the solution.
Then when a forum member takes their time to try and help, you have the audacity to post this comment "don't anyhow provide code which you are not sure".
Hopefully your next post on this forum will be way of an apology to johnl.
|
|
|
|
Users browsing this topic |
Guest (Hidden)
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.