DocsMathStatisticsCumulative Sum

Cumulative Sum

Full-series (no rolling window)Statistics

The Cumulative Sum node maintains a running total of all values from the beginning of the windowed series. Unlike Sum (which uses a sliding window), CumSum accumulates from bar zero onward. Once a valid value is encountered, subsequent nulls maintain the running total rather than resetting to null. CumSum converts rate-of-change series (log-returns) into level series (equity curves), and turns indicator deltas into cumulative measures.

Algorithm

  • Maintain a running total: S[0] = v[0]; S[i] = S[i−1] + v[i] for non-null v[i]
  • When v[i] is null and a valid value was seen: output = current running sum (carry forward)
  • When v[i] is null and no valid value seen yet: output = null
  • Does not use a rolling period — accumulates over the entire input array

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

Equity Curve

Feed log-returns or P&L-per-bar into CumSum to construct an equity curve showing the cumulative compound growth over time.

Cumulative Volume

Apply CumSum to a volume series to track total traded volume from the session open — equivalent to a running VWAP denominator.

OBV Alternative

Feed signed volume (volume × Sign(close change)) into CumSum to build an On-Balance Volume (OBV) indicator from primitives.