ta.roc
Measure the percentage change of a series over the last n bars.
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.
| Name | Kind | Type | Default | Range | Description |
|---|---|---|---|---|---|
source | Series | number | - | - | The series to read. |
length | Constant | number | - | 1 to 10000 | Window in observed bars. |
Output
| Name | Type |
|---|---|
value | number |
Warm-up and missing values
- Warm-up
lengthbars. Names in the warm-up are this operator’s parameters.- Missing values
- na until
lengthbars of history exist. na when the earlier observation is zero or na.
Example
ta.roc(close, 10)plot(ta.roc(close, 10), "Rate of change 10")