25 private decimal _rollingSum;
26 private decimal _rollingSumOfSquares;
33 : this($
"VAR({period})", period)
60 _rollingSum += input.
Value;
61 _rollingSumOfSquares += input.
Value * input.
Value;
66 var n = Math.Min(
Period, Samples);
67 var meanValue1 = _rollingSum / n;
68 var meanValue2 = _rollingSumOfSquares / n;
72 var removedValue = window[
Period - 1];
73 _rollingSum -= removedValue.Value;
74 _rollingSumOfSquares -= removedValue.Value * removedValue.Value;
78 return Math.Max(0m, meanValue2 - meanValue1 * meanValue1);
87 _rollingSumOfSquares = 0;