Docs

ta.lag

Read a series as it stood n bars ago.

itm
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.

NameKindTypeDefaultRangeDescription
sourceSeriesnumber--The series to read.
lengthConstantnumber11 to 10000How many bars back to read.

Output

NameType
valuenumber

Warm-up and missing values

Warm-up
length bars. Names in the warm-up are this operator’s parameters.
Missing values
na until length bars of history exist, and na when the observation length bars ago was itself na. The current bar being na does not matter, because this reads the past, not the present.

Example

itm
ta.lag(close, 1)
itm
plot(ta.lag(close, 5), "Close 5 bars ago")