Function hydra_dx_math::ema::smoothing_from_period
source · Expand description
Calculates smoothing factor alpha for an exponential moving average based on period
:
alpha = 2 / (period + 1)
. It leads to the “center of mass” of the EMA corresponding to be the
“center of mass” of a period
-length SMA.
Possible alternatives for alpha = 2 / (period + 1)
:
alpha = 1 - 0.5^(1 / period)
for a half-life ofperiod
oralpha = 1 - 0.5^(2 / period)
to have the same median as aperiod
-length SMA. See https://en.wikipedia.org/wiki/Moving_average#Relationship_between_SMA_and_EMA
Note: Not used in the pallet except to check configured values. Not meant to be used by code interacting with the pallet. Use the configured values.