Rolling Variance Pass Node

Rolling Variance — Series Input

StatisticalDistributionalPass

Overview

The Rolling Variance Pass Node computes the rolling sample variance of any numeric series — the average squared deviation from the rolling mean. It is the squared standard deviation and a fundamental measure of dispersion.

Variance is used directly in portfolio optimisation (covariance matrices), model inputs requiring squared-scale dispersion measures, and as a building block for higher-order moments.

Formula

Sample Variance (Bessel-corrected):
Var[i] = Σ(xⱼ − μ)² / (n − 1)
μ = rolling mean over window. n = period. Uses (n−1) denominator for unbiased sample variance.
Note: std deviation = √Var.

Parameters

ParameterDefaultDescription
period20Rolling window in bars

Inputs & Outputs

SlotDirectionTypeDescription
inputInput{ values, timestamps }Any upstream numeric series
valuesOutput(number | null)[]Sample variance per bar; nulls during warm-up
timestampsOutputnumber[]Unix timestamps aligned to input

Use Cases

Volatility Regime Detection

Track rolling variance of returns to identify low-variance (stable) vs high-variance (volatile) market regimes for position sizing.

Portfolio Optimisation Input

Rolling variance is the diagonal of the covariance matrix in mean-variance optimisation. Use alongside the Covariance node for full portfolio variance.

Normalised Signals

Divide signals by rolling variance (or std = √variance) to produce variance-normalised features for ML models or Z-score computation.

Tips & Best Practices

Variance vs StdDev

Variance is in squared units (e.g. squared percent). For human-readable volatility, use the square root (std deviation) or ATR-based measures instead.

Apply to Returns

Rolling variance of raw prices captures trend-induced dispersion. For true volatility analysis, compute variance on log-returns or simple returns.

Bessel Correction

This node uses the sample variance formula (÷ n−1). For population variance (÷ n), use when the window is the entire population of interest.

Related Indicators