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

Money Flow Index [Wikipedia](https://en.wikipedia.org/wiki/Money_flow_index).

With the typical price `TP = (high + low + close) / 3` and the raw money
flow `TP * volume`, over the lookback window:

`MFI = 100 - 100 / (1 + positive_flow / negative_flow)`

Bars are maps with at least `:high`, `:low`, `:close` and `:volume`. See
`TAlib` for the remaining conventions: chronological order, oldest
first, series aligned with the input, `nil` when there is not enough
data or the window has no movement.

# `mfi`

```elixir
@spec mfi([map()], pos_integer()) :: float() | nil
```

Calculate the latest Money Flow Index.

## Parameters

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

## Examples

    iex> bars = [
    ...>   %{high: 12, low: 8, close: 10, volume: 100},
    ...>   %{high: 13, low: 9, close: 12, volume: 200},
    ...>   %{high: 11, low: 9, close: 10, volume: 150}
    ...> ]
    iex> TAlib.Indicators.MFI.mfi(bars, 2) |> Float.round(4)
    60.177

# `mfi_list`

```elixir
@spec mfi_list([map()], pos_integer()) :: [float() | nil]
```

Calculate the full Money Flow Index series.

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

## Parameters

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

## Examples

    iex> bars = [
    ...>   %{high: 12, low: 8, close: 10, volume: 100},
    ...>   %{high: 13, low: 9, close: 12, volume: 200},
    ...>   %{high: 11, low: 9, close: 10, volume: 150}
    ...> ]
    iex> TAlib.Indicators.MFI.mfi_list(bars, 2) |> Enum.map(fn
    ...>   nil -> nil
    ...>   x -> Float.round(x, 4)
    ...> end)
    [nil, nil, 60.177]

---

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