ta.cumret
Measure the total return since the first bar, or since each period began, as a fraction.
ta.cumret(source, reset)Cumulative simple return from the first bar of the run, or of each period with reset: source / source[first] - 1, a fraction rather than a percentage. Simple compounding is the definition. For the log version write math.exp(ta.cum(ta.logret(close, 1))) - 1. It differs on a series with gaps, because ta.cum skips an na where this carries the last value.
Parameters
A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.
| Name | Kind | Type | Default | Range | Description |
|---|---|---|---|---|---|
source | Series | number | - | - | The series to read. |
reset | Constant | string | - | - | Restarts the base at the first bar of each session, day, week, month, quarter or year (an option, written reset=session). |
Output
| Name | Type |
|---|---|
value | number |
Warm-up and missing values
- Warm-up
- 1 bar.
- Missing values
- na until the first non-na observation, which is the base. na for the whole run if that base is zero. An na bar leaves the last value standing rather than resetting it. Each period starts empty.
Example
ta.cumret(close)plot(ta.cumret(close), "Return since start")