Divide

Element-wiseCore Math

The Divide node computes A ÷ B element-wise. Division by zero or null yields null safely — no exceptions are thrown. Supports a scalar denominator (useNumericB) for constant-factor division. Division is foundational for ratio-based metrics: RSI gain/loss ratio, profit factor, spread as percentage of price, and ATR-relative normalization.

Algorithm

  • Array / Array: output[i] = A[i] / B[i]
  • Array / Constant: output[i] = A[i] / numericB
  • B[i] === 0, null, or numericB === 0 → output null (zero-safe)

Parameters

NameTypeDefaultDescription
useNumericBbooleanfalseDivide by a constant number instead of a second array.
numericBnumber1The constant divisor when useNumericB is enabled.

Inputs & Outputs

PortTypeDescription
Inputs
input1number[]Primary input array A
input2number[]Secondary input array B (ignored when useNumericB is true)
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

ATR Normalization

Divide price differences by ATR to produce ATR-normalized values that are comparable across different volatility regimes.

Custom RSI Components

Divide a Gain series by a Loss series to produce the raw RS ratio, then transform via 100 - 100/(1+RS) to get RSI.

Profit Factor

Divide cumulative gain by cumulative loss over a rolling window to compute a real-time profit factor for open trades.