Cumulative Sum
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
| Port | Type | Description |
|---|---|---|
| Inputs | ||
| input | number[] | Source numeric array |
| Outputs | ||
| values | number | null | Computed value at each bar; null before the warmup period completes |
| timestamps | number[] | Bar timestamps (UNIX ms), aligned 1-to-1 with values |
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.