Square Root
Element-wiseCore Math
The Sqrt node computes Math.sqrt(x) per element. It is the core building block for standard deviation: compute variance first (Subtract mean → Pow(2) → Average), then apply Sqrt. Also used to convert squared ATR to ATR, to compute the magnitude of a vector component, and for any volatility measure derived from mean-squared values.
Algorithm
- ▸output[i] = Math.sqrt(input[i])
- ▸null inputs → null output
- ▸Negative inputs → NaN, which is treated as null downstream
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
Custom Standard Deviation
Chain Subtract, Pow(2), Average, then Sqrt to replicate a standard deviation without the dedicated Variance node.
RMS Amplitude
After Pow(2) and Average over a rolling window, apply Sqrt to produce the Root Mean Square (RMS) amplitude of any signal series.
Volatility Scaling
Scale position size by 1 / Sqrt(variance) to target a fixed notional volatility budget regardless of market regime.