'How to count how many times an event occurred in a time frame? V5
As the screenshot shows, I am trying to detect VWAP rebounds and if you may see, there's a huge bearish breakout on the right side of the image. My theory is, if I could count the number of how many times a bounce occurred then (combining with the trend of VWAP) I could be able to predict potential breakouts. Also in bullish context.
Is there a function to do this counting? Or any idea of a scripted workaround?
I can get the moment of Market Open, it could be the best start of the counting. Couldn't make ta.cum() work.
Solution 1:[1]
You can use this to count how many times your condition was true in the given length:
cnt = math.sum(cond ? 1 : 0, len)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | vitruvius |

