DocsMathStatisticsCoefficient of Variation

Coefficient of Variation

Windowed · default period 20Statistics

The Coefficient of Variation (CV) node computes (population std / |mean|) × 100 over the rolling window. CV is a normalized volatility measure — a CV of 20% means the typical spread is 20% of the average value. Because it divides by the mean, CV allows direct volatility comparison between assets with very different price levels. Returns null when the mean is zero.

Algorithm

  • Compute mean (μ) and population std (σ) of non-null window values
  • output = (σ / |μ|) × 100
  • Returns null when μ = 0 or fewer than 2 non-null values

Parameters

NameTypeDefaultDescription
periodnumber20Rolling window size.

Inputs & Outputs

PortTypeDescription
Inputs
inputnumber[]Source numeric array
Outputs
valuesnumber | nullComputed value at each bar; null before the warmup period completes
timestampsnumber[]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

Cross-Asset Volatility Comparison

CV enables comparing the relative volatility of a $10 stock with a $1000 stock without needing to normalize prices first.

Regime Filter

CV above a threshold (e.g., 5%) signals a high-volatility regime; below signals low-volatility compression — useful for switching between strategy modes.

Position Sizing Adjuster

Use 1/CV as a volatility-adjusted position size multiplier to maintain equal risk across different assets and regimes.