31 private readonly decimal[] _weightVector;
53 if (offset < 0 || offset > 1)
throw new ArgumentException($
"Offset parameter range is [0,1]. Value: {offset}", nameof(offset));
55 var m = Math.Floor(offset * (period - 1));
56 var s = period * 1m / sigma;
58 var tmpVector = Enumerable.Range(0, period)
59 .Select(i => Math.Exp((
double) (-(i - m) * (i - m) / (2 * s * s))))
62 _weightVector = tmpVector
63 .Select(i => (decimal) (i / tmpVector.Sum())).Reverse()
73 : this(name, period, 6)
90 : this($
"ALMA({period},{sigma},{offset})", period, sigma, offset)
116 ? window.Select((t, i) => t.Price * _weightVector[i]).Sum()