ta.logret
Measure the log return over the last n bars, which adds up across time.
ta.logret(source, length, session=false)Log return: ln(source / source[length]).
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. |
length | Constant | number | 1 | 1 to 10000 | Window in observed bars. |
session | Constant | bool | false | - | true: a return whose two observations fall on different trading days of the calendar (the overnight gap) is na, so the first bar of each session is na at length 1. No effect at daily or coarser bars or on a 24/7 calendar (an option, written session=true). |
Output
| Name | Type |
|---|---|
value | number |
Warm-up and missing values
- Warm-up
lengthbars. Names in the warm-up are this operator’s parameters.- Missing values
- na until
lengthbars of history exist. na when either observation is na or not positive. With session=true, also na when source and source[length] fall in different sessions.
Example
ta.logret(close, 1)plot(ta.logret(close, 1), "Log return")