how to count zigzag moves
- This topic has 4 replies, 3 voices, and was last updated 1 year ago by .
Viewing 5 posts - 1 through 5 (of 5 total)
Viewing 5 posts - 1 through 5 (of 5 total)
Similar topics:
Forums › ProRealTime English forum › ProBuilder support › how to count zigzag moves
Hi
I would like to count the quantity of zigzag moves of an index/security of a chart
ex: zigzag moves of 5% of the SPX index
I have tried a few things but what I get is kind strange, is it possible? The last attempt was this one but it gives an error message (the following variable is undefined: count )
thank you
a= ZigZagPoint[10](close)
b=count[a]
c=cumsum (b)
return c
Firstly, COUNT is not defined anywhere thus can’t be used.
Secondly, ZIGZAG returns a value each bar, it doesn’t count swing points, so counting it will return a huge number.
Thirdly, you can count swing points with this code, but it’s useless as it’s a repainting, so it may change any swing point several bars after they have already been counted as you will easily spot on a 1-second TF (see my attached pic):
1 2 3 4 5 6 7 8 |
ONCE Count = 0 myZZ = ZigZagPoint[10](close) SwingHI = (myZZ < myZZ[1]) AND (myZZ[1] > myZZ[2]) SwingLO = (myZZ > myZZ[1]) AND (myZZ[1] < myZZ[2]) IF SwingHI OR SwingLO THEN c = c + 1 ENDIF return c AS "Count" |
(Sorry same time as Roberto)
Hi,
You can try this one…
I think the calculation of the ZigZag is incorrect, for example if I set a 5% change (from bottom to top or vice versa) then the number of change (points) is incorrect…??
1 2 3 4 5 6 7 8 9 10 11 12 13 |
PercentChange=5 ZZ=ZigZag[PercentChange](Close) If ZZ[1]<ZZ[2] and ZZ>ZZ[1] then BottomCount=BottomCount+1 ElsIf ZZ[1]>ZZ[2] and ZZ<ZZ[1] then TopCount=TopCount+1 EndIf TotalCount=BottomCount+TopCount Return BottomCount as "BottomCount", TopCount as "TopCount", TotalCount as "TotalCount" |
Thank you it works, just return totalcount
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
PercentChange=5 ZZ=ZigZag[PercentChange](Close) If ZZ[1]<ZZ[2] and ZZ>ZZ[1] then BottomCount=BottomCount+1 ElsIf ZZ[1]>ZZ[2] and ZZ<ZZ[1] then TopCount=TopCount+1 EndIf TotalCount=BottomCount+TopCount Return BottomCount as "BottomCount", TopCount as "TopCount", TotalCount as "TotalCount" |
Find exclusive trading pro-tools on