34 private readonly
int _period;
39 public override bool IsReady => _rollingSum.IsReady;
54 if (period == 0)
throw new ArgumentException(
"Period can not be zero");
56 _rollingSum =
new Sum(name +
"_Sum", period);
64 : this($
"MGD({period})", period)
76 _rollingSum.Update(input.
Time, input.
Value);
82 if (Samples == _period)
84 return _rollingSum.Current.Value / _period;
87 if (Current.Value == 0 || input.
Value == 0)
92 var ratioValue = (double)input.
Value.SafeDivision(Current.Value, 0);
93 if (ratioValue == 0)
return Current.Value;
94 var denominator = _period * (decimal)Math.Pow(ratioValue, 4.0);
95 return Current.Value + (input.
Value - Current.Value).SafeDivision(denominator, 0);