27 private readonly
int _n = 16;
28 private readonly
double _w = -4.6;
43 throw new ArgumentException($
"{name}: N must be even, N = {n}", nameof(n));
46 _w = Math.Log(2d / (1 + longPeriod));
57 : this($
"FRAMA({n},{longPeriod})", n, longPeriod)
78 var price = (input.
High + input.
Low) / 2;
79 _high.Add((
double)input.
High);
80 _low.Add((
double)input.
Low);
83 if (_high.Samples <= _high.Size)
88 var hh = _high.Take(_n / 2).Max();
89 var ll = _low.Take(_n / 2).Min();
90 var n1 = (hh - ll) / (_n / 2);
92 hh = _high.Skip(_n / 2).Take(_n / 2).Max();
93 ll = _low.Skip(_n / 2).Take(_n / 2).Min();
95 var n2 = (hh - ll) / (_n / 2);
96 var n3 = (_high.Max() - _low.Min()) / _n;
100 if (n1 + n2 > 0 && n3 > 0)
102 var log = Math.Log((n1 + n2) / n3);
103 dimen = (
double.IsNaN(log) ? 0 : log) / Math.Log(2);
106 var alpha = Math.Exp(_w * (dimen - 1));
117 return (decimal)alpha * price + (1 - (decimal)alpha) * Current.Value;
123 public override bool IsReady => _high.IsReady;