Skip to content

Unary Math

Math · Transform

Unary Math node on the canvas

Apply a single-input transformation: absolute value, sign, negate, square root, natural log, exponential, or reciprocal (1/x). Domain failures (sqrt of negative, log of non-positive, 1/0) emit NaN.

Unary Math applies a single-input mathematical transform to a series: absolute value, sign, negate, square root, natural log, exponential, or reciprocal. These are the standard function-of-one-thing operations from maths, exposed as a block so you can reshape a series — take its magnitude, flip its sign, compress its scale — wherever a strategy needs it.

How it works

Wire a series (or Bars, using close) into the input and pick an Operation:

  • abs — magnitude, drops the sign (|x|).
  • sign — −1, 0, or +1 depending on direction.
  • negate — flips the sign (−x).
  • sqrt — square root (for scaling/variance work).
  • log — natural log (compresses large values; the basis of log returns).
  • exp — exponential (the inverse of log).
  • reciprocal1/x.

Domain failures emit NaN — sqrt of a negative, log of a non-positive, or 1/0 simply produce "no value" rather than erroring.

When to use it

Use Unary Math to reshape a series mathematically. abs turns a signed spread into a magnitude ("how far apart, regardless of direction"). sign extracts pure direction from any series. log compresses a wide-ranging series or builds log-return constructions. negate flips an indicator to combine it with another. These are plumbing operations — reach for the one that does the transform your formula needs.

Example

Magnitude of a spread: build close − SMA with Subtract, then apply Unary Math abs to get the distance from the average regardless of side — feed that into a Greater Than to detect "price is far from its mean" in either direction. Backtest in the Tester.

Tips & gotchas

  • Seven transforms in one — pick the function your formula needs.
  • Domain failures → NaN (sqrt of negative, log of ≤0, 1/0) — no crashes, just no value.
  • abs for magnitude, sign for direction — the two most-used in trading logic.
  • log compresses scale — useful before combining a wide-ranging series with others.

Inputs

Socket Type What to wire in
In series / bars Operand. BARS input uses close.

Outputs

Output Type Plots as Description
f(A) series Line · sub-pane Per-bar transformed value.

Parameters

Parameter Type Default What it does
Operation choice (abs, sign, negate, sqrt, log, exp, reciprocal) abs

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