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

Aroon indicator [Wikipedia](https://en.wikipedia.org/wiki/Aroon).

* `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.

# `aroon`

```elixir
@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`

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

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

    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`

```elixir
@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`

```elixir
@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`

```elixir
@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}

---

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