Docs

ta.roc

Measure the percentage change of a series over the last n bars.

itm
ta.roc(source, length)

Rate of change in percent: 100 * (source - source[length]) / source[length]. Of the three change-ratio operators only this one is scaled by 100. ta.ret and ta.pctchange give the same quantity as a fraction, so ta.roc(x, n) is exactly 100 * ta.ret(x, n).

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.
lengthConstantnumber-1 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.roc(close, 10)
itm
plot(ta.roc(close, 10), "Rate of change 10")