Systemicbeta

Subtract

systemic:core-subMath

Inputs

NameTypeDescription
First ValueNumber seriesThe series or constant to subtract **from** (the left side of the subtraction).
Second ValueNumber seriesThe series or constant to subtract (the right side of the subtraction).

Outputs

NameTypeDescription
DifferenceNumber seriesThe First Value minus the Second Value at each bar.

Cost

7
credits per run
1,000
bars

0.201 + 0.00624·n credits for n bars, rounded up. The marks are each plan's limit of bars.

Differencei=Ai−Bi\text{Difference}_i = A_i - B_i

Subtracts the second series from the first, bar by bar. Use it for spreads, price changes and deviations.

First (A)Second (B)Difference
1008020
80100-20
50500

Missing Data

If either input is empty at a bar (a data gap or a closed-market day), the difference at that bar is empty. The module never fills a gap: a gap in your inputs stays a gap in the output.

FirstSecondDifference
100emptyempty
empty80empty
emptyemptyempty

A result can also be mathematically undefined: subtracting +∞ from +∞ (or −∞ from −∞) has no answer, so that bar is empty even though both inputs have a value. Any other infinite result is returned unchanged.


Input Alignment

Systemic aligns the two inputs before it subtracts:

ScenarioWhat Happens
Different start datesThe result starts where both inputs have data
Different periodsThe slower series is repeated on every bar of the faster one
One constantThe constant is used on every bar of the series

Example: BTC (1h) − ETH (15m) → each 15m bar uses the most recent 1h BTC value.


Order Matters

Subtraction is not commutative: A − B ≠ B − A

InputsResultInterpretation
Price − SMA+20Price is 20 above average
SMA − Price-20Average is 20 below price

Choose the input order that gives the sign you want.


Practical Example: Price Deviation from Moving Average

Subtracting a 20-bar SMA from the price creates a deviation indicator:

Use CaseInterpretation
Price − SMA > 0Price above average (potentially overbought)
Price − SMA < 0Price below average (potentially oversold)
Price − SMA → 0Reverting to mean

Plotted over time, this deviation shows momentum shifts and possible reversal zones. Many mean-reversion strategies build on it and raise a signal when the deviation exceeds its historical range.


  • ADD — Adds two series bar by bar
  • DIV — Normalizes a difference (for example, percentage deviation)
  • ABS — Absolute deviation (distance without sign)
© 2026 WanoLabs. All rights reservedBeta v0.1.5