# `TAlib.Indicators.ROC`
[🔗](https://github.com/benyblack/talib/blob/main/lib/indicators/roc.ex#L1)

Rate of Change [Wikipedia](https://en.wikipedia.org/wiki/Momentum_(technical_analysis)).

`ROC = (price / price_period_bars_ago - 1) * 100`

See `TAlib` for the input conventions: prices are always given in
chronological order, oldest first, and the series is returned aligned
with the input. `nil` is returned when there is not enough data. Prices
must be non-zero for the division to be defined.

# `roc`

```elixir
@spec roc([number()], pos_integer()) :: float() | nil
```

Calculate the latest Rate of Change, in percent.

## Parameters

  - prices: list of prices, oldest first.
  - period: how many bars back to compare against, a positive integer (default 14).

## Examples

    iex> TAlib.Indicators.ROC.roc([1, 2, 4, 8], 2)
    300.0

# `roc_list`

```elixir
@spec roc_list([number()], pos_integer()) :: [float() | nil]
```

Calculate the full Rate of Change series in a single pass.

Returns a list aligned with `prices`: the first `period` entries are
`nil`, and every later entry is the rate of change over `period` bars.

## Parameters

  - prices: list of prices, oldest first.
  - period: how many bars back to compare against, a positive integer (default 14).

## Examples

    iex> TAlib.Indicators.ROC.roc_list([1, 2, 4, 8], 2)
    [nil, nil, 300.0, 300.0]

# `rocp`

```elixir
@spec rocp([number()], pos_integer()) :: float() | nil
```

Rate of change Percentage: `(price / lagged price) - 1`.

    iex> TAlib.Indicators.ROC.rocp([1, 2, 4, 8], 2)
    3.0

# `rocr100`

```elixir
@spec rocr100([number()], pos_integer()) :: float() | nil
```

Rate of change Ratio scaled by 100: `100 * price / lagged price`.

    iex> TAlib.Indicators.ROC.rocr100([1, 2, 4, 8], 2)
    400.0

# `rocr`

```elixir
@spec rocr([number()], pos_integer()) :: float() | nil
```

Rate of change Ratio: `price / lagged price`.

    iex> TAlib.Indicators.ROC.rocr([1, 2, 4, 8], 2)
    4.0

---

*Consult [api-reference.md](api-reference.md) for complete listing*
