Count
Windowed · default period 20Statistics
The Count node returns the number of non-null, non-NaN values present in the rolling window. While straightforward, Count is essential for validation pipelines — confirming that enough data exists before acting on downstream statistical outputs, and for building data-density indicators when upstream nodes may emit sparse null values.
Algorithm
- ▸Collect non-null, non-NaN values in the window
- ▸output = count of valid values
- ▸Returns null if zero valid values are found
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| period | number | 20 | Rolling window size. |
Inputs & Outputs
| Port | Type | Description |
|---|---|---|
| Inputs | ||
| input | number[] | Source numeric array |
| Outputs | ||
| values | number | null | Computed value at each bar; null before the warmup period completes |
| timestamps | number[] | Bar timestamps (UNIX ms), aligned 1-to-1 with values |
Live mode: In live streaming mode the node updates only the last bar in-place rather than recalculating the full array, keeping CPU usage minimal during real-time data feeds.
Use Cases
Data Density Guard
Gate signal generation when Count < period × 0.8, ensuring at least 80% of the window is populated before trusting statistical outputs.
Sparse Series Analysis
Use Count on a filtered series (e.g., bars where volume exceeds a threshold) to count how many qualifying bars appear in the last N bars.
Lookback Warmup Detection
Count the number of valid bars from the start of a series to know when a rolling indicator has warmed up sufficiently to be trusted.