28 private readonly
int _period;
31 private readonly
Sum _sumBuyingPressure1;
32 private readonly
Sum _sumBuyingPressure2;
33 private readonly
Sum _sumBuyingPressure3;
34 private readonly
Sum _sumTrueRange1;
35 private readonly
Sum _sumTrueRange2;
36 private readonly
Sum _sumTrueRange3;
45 : this($
"ULTOSC({period1},{period2},{period3})", period1, period2, period3)
59 _period = Math.Max(Math.Max(period1, period2), period3);
61 _sumBuyingPressure1 =
new Sum(name +
"_BP1", period1);
62 _sumBuyingPressure2 =
new Sum(name +
"_BP2", period2);
63 _sumBuyingPressure3 =
new Sum(name +
"_BP3", period3);
64 _sumTrueRange1 =
new Sum(name +
"_TR1", period1);
65 _sumTrueRange2 =
new Sum(name +
"_TR2", period2);
66 _sumTrueRange3 =
new Sum(name +
"_TR3", period3);
72 public override bool IsReady => Samples > _period;
86 _trueRange.Update(input);
90 _previousInput = input;
96 _sumBuyingPressure1.Update(buyingPressure);
97 _sumBuyingPressure2.Update(buyingPressure);
98 _sumBuyingPressure3.Update(buyingPressure);
100 _sumTrueRange1.Update(_trueRange.Current);
101 _sumTrueRange2.Update(_trueRange.Current);
102 _sumTrueRange3.Update(_trueRange.Current);
104 _previousInput = input;
109 if (_sumTrueRange1.Current.Value == 0
110 || _sumTrueRange2.Current.Value == 0
111 || _sumTrueRange3.Current.Value == 0)
113 return Current.
Value;
116 var average1 = _sumBuyingPressure1.Current.Value / _sumTrueRange1.Current.Value;
117 var average2 = _sumBuyingPressure2.Current.Value / _sumTrueRange2.Current.Value;
118 var average3 = _sumBuyingPressure3.Current.Value / _sumTrueRange3.Current.Value;
120 return 100m * (4 * average1 + 2 * average2 + average3) / 7;
128 _previousInput =
null;
130 _sumBuyingPressure1.Reset();
131 _sumBuyingPressure2.Reset();
132 _sumBuyingPressure3.Reset();
133 _sumTrueRange1.Reset();
134 _sumTrueRange2.Reset();
135 _sumTrueRange3.Reset();