/// <inheritdoc /> public IList <IndicatorValue> Calculate(IList <Price> prices) { var gains = new List <IndicatorValue>(); var losses = new List <IndicatorValue>(); for (var i = 1; i < prices.Count; i++) { var change = prices[i].ClosePrice - prices[i - 1].ClosePrice; if (change > 0) { gains.Add(new IndicatorValue { Date = prices[i].Date, Value = change }); losses.Add(new IndicatorValue { Date = prices[i].Date, Value = 0 }); } else { losses.Add(new IndicatorValue { Date = prices[i].Date, Value = -change }); gains.Add(new IndicatorValue { Date = prices[i].Date, Value = 0 }); } } var averageGains = MovingAverageHelper.SmoothedMovingAverage(gains, Term); var averageLosses = MovingAverageHelper.SmoothedMovingAverage(losses, Term); return(ComputeRsiValues(averageGains, averageLosses)); }
/// <inheritdoc /> public IList <IndicatorValue> Calculate(IList <Price> prices) { var rsValues = GetRsValues(prices); return(MovingAverageHelper.SmoothedMovingAverage(rsValues, Term)); }