Loss

Windowed · default period 20Statistics

The Loss node sums the absolute magnitude of all negative first differences within the rolling window — the total downward movement expressed as a positive number. It is the directional complement to the Gain node. Dividing Gain by Loss gives the classic Relative Strength (RS) ratio used in RSI computation. Requires at least 2 non-null values.

Algorithm

  • Compute consecutive differences: d[i] = vals[i] − vals[i−1]
  • Loss = Σ |d[i]| for all d[i] < 0 (only negative changes, returned as positive)
  • Returns null with 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

RSI from Primitives

Compute Gain and Loss, divide Gain/Loss for RS, then 100 − 100/(1+RS) — this reconstructs RSI from scratch using just the Gain, Loss, Divide, and Subtract nodes.

Loss Velocity

Apply Slope to the Loss series to measure how quickly downward pressure is accelerating — a high and rising Loss with falling Gain warns of increasing bearish momentum.

Directional Stress

Compare Loss / (Gain + Loss) to see what fraction of recent movement has been downward — values above 0.6 indicate sustained selling pressure.