TAlib.Indicators.CMO (TAlib v0.13.0)

Copy Markdown View Source

Chande Momentum Oscillator: 100 * (sum of gains - sum of losses) / (sum of gains + sum of losses) over the lookback window.

See TAlib for the 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 or the window has no movement.

Summary

Functions

Calculate the latest Chande Momentum Oscillator value.

Calculate the full CMO series.

Functions

cmo(prices, period \\ 14)

@spec cmo([number()], pos_integer()) :: float() | nil

Calculate the latest Chande Momentum Oscillator value.

Parameters

  • prices: list of prices, oldest first.
  • period: lookback window, a positive integer (default 14).

Examples

iex> TAlib.Indicators.CMO.cmo([1, 2, 3, 4, 3, 5], 2) |> Float.round(4)
33.3333

cmo_list(prices, period \\ 14)

@spec cmo_list([number()], pos_integer()) :: [float() | nil]

Calculate the full CMO series.

Returns a list aligned with prices: the first period entries are nil, and every later entry is the oscillator of the window ending at that point.

Parameters

  • prices: list of prices, oldest first.
  • period: lookback window, a positive integer (default 14).

Examples

iex> TAlib.Indicators.CMO.cmo_list([1, 2, 3, 4, 3, 5], 2) |> Enum.map(fn
...>   nil -> nil
...>   x -> Float.round(x, 4)
...> end)
[nil, nil, 100.0, 100.0, 0.0, 33.3333]