Docs

ta.pctchange

Take the fractional change of a series over the last n bars.

itm
ta.pctchange(source, length)

source / source[length] - 1, a fraction: exactly ta.ret, under its statistics name. The percentage version is ta.roc, which is this times 100. That settles the roc, ret and pctchange confusion: ta.roc is the only one of the three scaled by 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.pctchange(close, 1)
itm
plot(ta.pctchange(close, 1), "Percent change")