ta.lag
Read a series as it stood n bars ago.
ta.lag(source, length)The value the source had length bars ago: exactly source[length], as an operator, so a generated script need not write a history reference to say it.
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 | How many bars back to read. |
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, and na when the observationlengthbars ago was itself na. The current bar being na does not matter, because this reads the past, not the present.
Example
ta.lag(close, 1)plot(ta.lag(close, 5), "Close 5 bars ago")