roc
forge.tafunctionSince Forge API 1
Functionpython
forge.ta.roc(source: ArrayLike,period: int = 12,method: str = 'percent') -> np.ndarrayChange over period bars, as a percent, a fraction or a ratio.
Parameters
| Name | Type | Default |
|---|---|---|
| source | ArrayLike | |
| period | int | 12 |
| method | str | 'percent' |
percent is 100 * (price - earlier) / earlier, fraction the same without the 100,
ratio is price / earlier and ratio100 is 100 * price / earlier. mt5 is
MetaTrader 5's 100 * (price - earlier) / price, which divides by the current price. A zero
denominator leaves the bar empty.
Classpython
forge.ta.ROC(**inputs: Any) -> NoneChange 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 |
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.