Power
The Power node raises each element x to the exponent p (Math.pow(x, p)). Default is p=2 (squaring). Used to compute squared deviations (the first step of variance), apply polynomial transformations to signals, create quadratic scaling for penalty functions, and implement any indicator that requires raising values to arbitrary powers.
Algorithm
- ▸output[i] = Math.pow(input[i], p)
- ▸null inputs → null output
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| p | number | 2 | Exponent. Defaults to 2 (squaring). Use 0.5 for square root, negative values for reciprocals. |
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 |
Use Cases
Variance From Scratch
Subtract the mean from a price series (Subtract + Average), then Pow with p=2, then Average again — this produces the exact population variance without a dedicated node.
Penalty Scaling
Apply Pow(p=2) to a drawdown series to give quadratic penalty weight to larger drawdowns in a composite risk score.
Square Root via Pow
Set p=0.5 as an alternative to the dedicated Sqrt node — identical results, useful when you already have a Pow node in the pipeline.