Docs

ta.ret

Measure the simple return over the last n bars as a fraction.

itm
ta.ret(source, length)

Simple return: source / source[length] - 1, as a fraction. It is the transform a rolling beta or correlation is usually taken over. ta.pctchange is exactly this operator under another name, and ta.roc is this times 100.

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 10000Window in observed bars.

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. na when the earlier observation is zero or na.

Example

itm
ta.ret(close, 1)
itm
plot(ta.ret(close, 1), "Return")