Rate of Change Wikipedia.
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.
Summary
Functions
Calculate the latest Rate of Change, in percent.
Calculate the full Rate of Change series in a single pass.
Rate of change Percentage: (price / lagged price) - 1.
Rate of change Ratio scaled by 100: 100 * price / lagged price.
Rate of change Ratio: price / lagged price.
Functions
@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
@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]
@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
@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
@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