Count True
Counts intervals in a lookback window during which an ordinary condition was true at least once. countInterval chooses the counting interval; if omitted, it is one unit of the window interval. A five-minute interval contributes at most one count, even when the condition is true repeatedly. Separate visits can be expressed in the condition by requiring a previous bar outside the zone. TradingDay follows the input markets: crypto-only inputs use elapsed 24-hour days, including weekends, just like Day. Stock, option, mixed-market and asset-free expressions use confirmed exchange sessions. The window does not change intraday prices into daily closing prices. TradingMinute counts regular-session minutes the same way, so a 70 TradingMinute window at 9:45 reaches back to 3:06 PM on the prior session (the overnight gap is one step); crypto-only inputs use elapsed minutes. It allows at most 1439 minutes; use TradingDay for longer lookbacks. Indicators read every tick have no TradingMinute value outside regular hours, and windows over a ChartBar keep the value of its latest completed candle.
Count True
Definition
Counts intervals in a lookback window during which an ordinary condition was true at least once. countInterval chooses the counting interval; if omitted, it is one unit of the window interval. A five-minute interval contributes at most one count, even when the condition is true repeatedly. Separate visits can be expressed in the condition by requiring a previous bar outside the zone. TradingDay follows the input markets: crypto-only inputs use elapsed 24-hour days, including weekends, just like Day. Stock, option, mixed-market and asset-free expressions use confirmed exchange sessions. The window does not change intraday prices into daily closing prices. TradingMinute counts regular-session minutes the same way, so a 70 TradingMinute window at 9:45 reaches back to 3:06 PM on the prior session (the overnight gap is one step); crypto-only inputs use elapsed minutes. It allows at most 1439 minutes; use TradingDay for longer lookbacks. Indicators read every tick have no TradingMinute value outside regular hours, and windows over a ChartBar keep the value of its latest completed candle.
Parameters
Condition, Lookback window, Counting interval (optional)
Example
`CountTrue(condition, 20, TradingDay, {length: 5, interval: Minute})` counts matching five-minute intervals within the last 20 trading sessions. `CountTrue(condition, 30, Day)` counts matching calendar days within the last 30 days.
Full indicator reference