# Rate of change

`roc`

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 | Kind |
| --- | --- |
| roc | value |

Warm-up: period bars (12 at the defaults).

Repaints: No.

## 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.
