cumsum
Running total from start of data
cumsum(source)
Parameters
| Name | Type | Description |
|---|---|---|
source |
field | Data series to accumulate |
Formula
cumsum[n] = source[0] + source[1] + source[2] + ... + source[n]
Examples
// lifetime volume exceeds 1 billion shares
cumsum(volume) > 1B;
// more lifetime gains than losses (long-term uptrend)
cumsum(gain(close)) > cumsum(loss(close));
// stocks with at least 100 bullish days in history
cumsum(cond(close > open, 1, 0)) >= 100;
// net change from first recorded price
cumsum(change(close, 1)) > 0;
Returns
float
Notes
Scans the entire price history for each symbol, so use additional filters to limit the universe or the scan may time out; unlike sum(source, n)'s rolling window of N bars, cumsum() has no period parameter and always accumulates from the start of data; the result grows continuously, always increasing for a monotonic series like volume