Docs

ta.logret

Measure the log return over the last n bars, which adds up across time.

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

NameKindTypeDefaultRangeDescription
sourceSeriesnumber--The series to read.
lengthConstantnumber11 to 10000Window in observed bars.
sessionConstantboolfalse-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

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 either observation is na or not positive. With session=true, also na when source and source[length] fall in different sessions.

Example

itm
ta.logret(close, 1)
itm
plot(ta.logret(close, 1), "Log return")