Tool
Arithmetic
math.arithmetic
Inputs
The first operand series.
The second operand series (used only by two-operand modes).
Outputs
A number line carrying the result of the chosen operation, one value per bar.
Arithmetic is an all-in-one calculator node that runs one operation per bar on the series you wire in. A single `mode` picker switches it between basic math, single-value math, time shifting, rolling-window reductions, and normalization.
How it works
Pick a `mode` and the inspector greys out the knobs that don't apply, then the node computes that operation on input `a` (and `b` for two-operand modes like add or divide), producing a float series. Window modes use `period`, shift uses `n`, and clamp uses `min`/`max`.
Modes
Adds a and b on each bar.
When to use: Combine two series, e.g. sum two oscillators.
Subtracts b from a.
When to use: Spread between two lines, e.g. two MAs.
Multiplies a by b.
When to use: Scale or weight one series by another.
Divides a by b.
When to use: Ratios, e.g. price over a moving average.
Remainder of a divided by b.
When to use: Cyclic or periodic remainders.
Raises a to the power b.
When to use: Non-linear emphasis of a series.
The smaller of a and b each bar.
When to use: Floor one series by another.
The larger of a and b each bar.
When to use: Cap one series by another.
Absolute value of a.
When to use: Size of a move ignoring its sign.
Square root of a.
When to use: Compress large values.
e raised to a.
When to use: Exponential weighting.
Natural log of a.
When to use: Compress exponential growth or log returns.
Flips the sign of a.
When to use: Invert a series.
-1, 0, or +1 by the sign of a.
When to use: Reduce a series to direction only.
Rounds a down to an integer.
When to use: Bucket values downward.
Rounds a up to an integer.
When to use: Bucket values upward.
Rounds a to the nearest integer.
When to use: Snap to whole values.
Moves the series n bars in time.
When to use: Compare a value to its earlier self.
Sum over the last `period` bars.
When to use: Cumulative flow over a window.
Average over the last `period` bars.
When to use: Smooth a series.
Lowest value in the last `period` bars.
When to use: Recent support / lowest low.
Highest value in the last `period` bars.
When to use: Recent resistance / highest high.
Rescales the window to 0–1.
When to use: Put a series on a fixed scale.
Standard deviations from the window mean.
When to use: Detect statistical extremes.
Where the latest value sits in the window (0–1).
When to use: Relative strength within a window.
Pins the value between min and max.
When to use: Bound a series to a safe range.
Configuration
Which operation to run: basic math (add, sub, mul, div, mod, pow, min2, max2), single-value math (abs, sqrt, exp, log, neg, sign, floor, ceil, round), time shift (shift), rolling-window reductions (sum_window, mean_window, min_window, max_window), or normalization (normalize, z_score, percentile_rank, clamp).
Bars to shift when mode is shift — positive looks back, negative looks ahead (the look-ahead case is flagged repainting).
How many bars the rolling window covers, used by the window and normalization modes.
The lower bound the value is pinned to when mode is clamp.
The upper bound the value is pinned to when mode is clamp.
Connects to
Examples
- Set mode to sub and wire two moving averages into a and b to output the spread between them as a signal source.
- Set mode to z_score with a 20-bar period to turn a raw series into a normalized score you can threshold.
Common mistakes
- Using a binary mode like div but only wiring input a, leaving the second operand unset.
- Choosing a backward shift (negative n) and not realising it peeks at future bars — that mode is flagged repainting and can leak look-ahead bias.