Skip to content

Divide

Math · Arithmetic

Divide node on the canvas

Divide A by B element-wise. Useful for ratios ('close / sma', 'short EMA / long EMA'). Divide-by-zero produces NaN (engine treats as 'no value').

Divide takes one series and divides it by another — A over B — bar by bar. Division is how you build ratios, and ratios are how you compare two things on a common footing: price relative to its average, a fast average relative to a slow one, one instrument relative to another.

How it works

Each bar the block outputs A ÷ B. Either input can be Bars (uses close) or a series. Divide-by-zero produces NaN (the engine treats it as "no value"), so a zero in B won't crash the graph — it just yields no value on that bar.

When to use it

Use Divide to form a ratio. close / SMA gives a normalised "how far above/below average" reading that's comparable across price levels (1.0 = at the average, 1.02 = 2% above). fast EMA / slow EMA measures trend stretch. Dividing one instrument's price by another builds a relative-strength or pair ratio. Ratios are especially handy because they're scale-free — a 1.02 reading means the same thing whether price is 1.10 or 110.

Example

A relative-position oscillator: Divide price (A) by a 50-SMA (B) to get a ratio that hovers around 1.0; feed it into a Greater Than against 1.0 for "above average," or into Standardize to z-score it. Backtest in the Tester.

Tips & gotchas

  • Divide-by-zero → NaN, not an error — the bar just has no value.
  • Ratios are scale-free — that's their advantage for cross-level/cross-instrument comparison.
  • Order matters — A/B, not B/A.
  • A ratio near 1.0 centres nicely; Subtract instead if you'd rather centre on 0.

Inputs

Socket Type What to wire in
A series / bars First operand. BARS input uses close.
B series / bars Second operand. BARS input uses close.

Outputs

Output Type Plots as Description
A ÷ B series Line · sub-pane Per-bar element-wise result.

Reference auto-generated from the block catalog · category Math.