Indicado.EMA (Indicado v0.0.4) View Source
This is the EMA module used for calculating Exponential Moving Average
Link to this section Summary
Functions
Calculates EMA for the list. It needs non empty list of numbers and a positive period argument.
Calculates EMA for the list. It needs non empty list of numbers and a positive period argument.
Link to this section Functions
Specs
eval([list(), ...], pos_integer()) :: {:ok, [float(), ...] | {:error, atom()}}
Calculates EMA for the list. It needs non empty list of numbers and a positive period argument.
Returns {:ok, ema_list}
or {:error, reason}
Examples
iex> Indicado.EMA.eval([1, 2, 3, 4], 2)
{:ok, [1.0, 1.6666666666666665, 2.5555555555555554, 3.518518518518518]}
iex> Indicado.EMA.eval([2, 4, 5, 10, 100, 1000], 3)
{:ok, [2.0, 3.0, 4.0, 7.0, 53.5, 526.75]}
iex> Indicado.EMA.eval([2, 4, 5, 10, 100, 1000], 5)
{:ok, [2.0, 2.666666666666667, 3.4444444444444446, 5.62962962962963, 37.08641975308642, 358.0576131687243]}
iex> Indicado.EMA.eval([], 2)
{:error, :not_enough_data}
iex> Indicado.EMA.eval([1, 2, 3, 4], 0)
{:error, :bad_period}
Specs
eval!([list(), ...], pos_integer()) :: [float(), ...] | no_return()
Calculates EMA for the list. It needs non empty list of numbers and a positive period argument.
Raises NotEnoughDataError
if the given list is not longh enough for calculating RSI.
Raises BadPeriodError
if period is an unacceptable number.
Examples
iex> Indicado.EMA.eval!([1, 2, 3, 4], 2)
[1.0, 1.6666666666666665, 2.5555555555555554, 3.518518518518518]
iex> Indicado.EMA.eval!([], 2)
** (NotEnoughDataError) not enough data
iex> Indicado.EMA.eval!([1, 3, 4], 0)
** (BadPeriodError) bad period