TAlib.Indicators.Aroon (TAlib v0.13.0)

Copy Markdown View Source

Aroon indicator Wikipedia.

  • Aroon Up = 100 * index of the window's highest high / period
  • Aroon Down = 100 * index of the window's lowest low / period

The window spans period + 1 prices (or bars), so 100 means the extreme is the latest value and 0 means it is period bars old. On ties the earliest occurrence in the window wins. Aroon Oscillator = Up - Down. See TAlib for the conventions: chronological input, series aligned with the input, nil for insufficient data.

Summary

Functions

Calculate the latest Aroon Up / Down as a map, over closing prices.

The Aroon Up / Down series over closing prices, aligned with the input (period leading nils).

The Aroon Oscillator: Up - Down, ranging from -100 to 100.

Warm up streaming Aroon state from history (closing prices).

Advance streaming Aroon state by one price, in O(1): {state, {up, down}}.

Functions

aroon(prices, period \\ 14)

@spec aroon([number()], pos_integer()) :: %{up: float(), down: float()} | nil

Calculate the latest Aroon Up / Down as a map, over closing prices.

Parameters

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

Examples

iex> TAlib.Indicators.Aroon.aroon([5, 3, 8, 2, 6, 9, 4], 3) |> Enum.sort()
[down: 0.0, up: 66.66666666666667]

aroon_list(prices, period \\ 14)

@spec aroon_list([number()], pos_integer()) :: [{float(), float()} | nil]

The Aroon Up / Down series over closing prices, aligned with the input (period leading nils).

iex> TAlib.Indicators.Aroon.aroon_list([5, 3, 8, 2, 6, 9, 4], 3) |> Enum.take(-2)
[{100.0, 33.333333333333336}, {66.66666666666667, 0.0}]

aroon_osc(prices, period \\ 14)

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

The Aroon Oscillator: Up - Down, ranging from -100 to 100.

iex> TAlib.Indicators.Aroon.aroon_osc([5, 3, 8, 2, 6, 9, 4], 3) |> Float.round(4)
66.6667

init(prices, period \\ 14)

@spec init([number()], pos_integer()) ::
  {TAlib.Indicators.Aroon.State.t(), [{float(), float()} | nil]}

Warm up streaming Aroon state from history (closing prices).

Returns {state, values} with values the full {up, down} series of history (identical to aroon_list/2), and state ready to continue it one price at a time in O(1) via next/2. History needs at least period + 1 prices.

Examples

iex> {state, values} = TAlib.Indicators.Aroon.init([5, 3, 8, 2, 6, 9, 4], 3)
iex> Enum.take(values, -2)
[{100.0, 33.333333333333336}, {66.66666666666667, 0.0}]
iex> {_state, {100.0, 66.66666666666667}} = TAlib.Indicators.Aroon.next(state, 10)

next(state, price)

@spec next(TAlib.Indicators.Aroon.State.t(), number()) ::
  {TAlib.Indicators.Aroon.State.t(), {float(), float()} | nil}

Advance streaming Aroon state by one price, in O(1): {state, {up, down}}.

iex> {state, _} = TAlib.Indicators.Aroon.init([5, 3, 8, 2, 6, 9, 4], 3)
iex> {_state, value} = TAlib.Indicators.Aroon.next(state, 10)
iex> value
{100.0, 66.66666666666667}