Round

Element-wiseCore Math

The Round node applies Math.round to each element, rounding to the nearest integer (ties round toward positive infinity, matching JavaScript semantics). Used for discretizing outputs to tick resolution, rounding computed prices before order placement, normalizing integer-valued metrics such as bar counts or period lengths, and producing clean display values.

Algorithm

  • output[i] = Math.round(input[i])
  • null inputs → null output

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

Order Price Rounding

Round a computed entry price to the nearest tick before passing it to an order management node to avoid sub-tick price rejections.

Dynamic Period Rounding

Round a volatility-adjusted period (e.g., 14 × vol_ratio) to the nearest integer before feeding into a rolling stat node that requires integer periods.

Display Normalization

Round indicator outputs to 2 decimal places by multiplying by 100, rounding, then dividing by 100 — using Round as the middle step.