TAlib.Indicators.OBV (TAlib v0.13.0)

Copy Markdown View Source

On-Balance Volume Wikipedia.

A running total of volume, added when the close rises and subtracted when it falls. Matching TA-Lib, the line is seeded with the first bar's volume; the first bar itself carries no change.

Bars are maps with at least :close and :volume. See TAlib for the remaining conventions: chronological order, oldest first, series aligned with the input.

Summary

Functions

Calculate the latest On-Balance Volume.

Calculate the full On-Balance Volume series.

Functions

obv(bars)

@spec obv([map()]) :: number() | nil

Calculate the latest On-Balance Volume.

Parameters

  • bars: list of bars, oldest first.

Examples

iex> bars = [
...>   %{close: 5, volume: 10},
...>   %{close: 6, volume: 20},
...>   %{close: 5, volume: 30},
...>   %{close: 7, volume: 40}
...> ]
iex> TAlib.Indicators.OBV.obv(bars)
40

obv_list(list)

@spec obv_list([map()]) :: [number()]

Calculate the full On-Balance Volume series.

Returns a list aligned with bars (the first entry is the first bar's volume, as in TA-Lib).

Parameters

  • bars: list of bars, oldest first.

Examples

iex> bars = [
...>   %{close: 5, volume: 10},
...>   %{close: 6, volume: 20},
...>   %{close: 5, volume: 30},
...>   %{close: 7, volume: 40}
...> ]
iex> TAlib.Indicators.OBV.obv_list(bars)
[10, 30, 0, 40]