48 private int _trendStreak;
68 WarmUpPeriod = Math.Max(rsiPeriod, Math.Max(rsiPeriodStreak, lookBackPeriod));
76 : this($
"CRSI({rsiPeriod},{rsiPeriodStreak},{rocPeriod})", rsiPeriod, rsiPeriodStreak, rocPeriod)
84 public override bool IsReady => _rsi.IsReady && _srsi.IsReady && _priceChangeRatios.IsReady;
104 ComputeTrendStreak(input);
107 if (_previousInput ==
null || _previousInput.
Value == 0)
109 _previousInput = input;
110 _priceChangeRatios.Add(0m);
115 var relativeMagnitude = 0m;
116 var priceChangeRatio = (input.
Value - _previousInput.
Value) / _previousInput.
Value;
117 if (_priceChangeRatios.IsReady)
120 relativeMagnitude = 100m * _priceChangeRatios.Count(x => x < priceChangeRatio) / _priceChangeRatios.Count;
122 _previousInput = input;
128 _priceChangeRatios.Add(priceChangeRatio);
129 return (_rsi.Current.Value + _srsi.Current.Value + relativeMagnitude) / 3;
132 _priceChangeRatios.Add(priceChangeRatio);
143 if (_previousInput ==
null)
147 var change = input.
Value - _previousInput.
Value;
149 if ((_trendStreak > 0 && change < 0) || (_trendStreak < 0 && change > 0))
172 _priceChangeRatios.Reset();