Average
Windowed · default period 20Statistics
The Average node computes the arithmetic mean of all non-null values in the rolling window — equivalent to a Simple Moving Average (SMA). It is the most fundamental rolling statistic, serving as the baseline for deviation, z-score calculation, Bollinger Bands, and many classical technical indicators. Null values within the window are ignored (not zero-filled).
Algorithm
- ▸Collect non-null, non-NaN values in the window
- ▸output = sum(vals) / count(vals)
- ▸Returns null if no non-null values exist in the window
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| period | number | 20 | Rolling window size (SMA period). |
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
Simple Moving Average
Connect closing prices and set period=20 to get a 20-bar SMA — the building block of countless trend and crossover systems.
Mean-Deviation Oscillator
Subtract Average(close, 20) from close to build a centered oscillator showing how far price deviates from its 20-bar mean.
Bollinger Band Middle
The Average output is the Bollinger middle band. Combine with Variance and Sqrt for the full Bollinger Band construction.