Rate of change
Change over a number of bars as a percent, fraction or ratio.
Inputs
| Name | Type | Default | Range |
|---|---|---|---|
| source | source | close | |
| period | int | 12 | 1 to 5000 |
| method | choice | percent |
Outputs
| Name | Type | Required | Description |
|---|---|---|---|
| roc | value | Optional | color theme.accent, style line, width 1 |
- Warm-up
- period bars (12 at the defaults)
- Repaints
- No
- Parity
- TA-Lib, within 1e-9
Formula
percent: 100 * (x[i] - x[i-period]) / x[i-period]
fraction: (x[i] - x[i-period]) / x[i-period]
ratio: x[i] / x[i-period]
ratio100: 100 * x[i] / x[i-period]
mt5: 100 * (x[i] - x[i-period]) / x[i], the MetaTrader 5 form
A zero denominator leaves the bar empty.