/// <summary> /// Calculates next RSI value from previous /// </summary> /// <param name="previousRSI">Previous RSI value</param> /// <param name="latestCandlestick">Last candlestick</param> /// <returns>Updated RSI value</returns> public virtual RSIValue CalculateNextValue(RSIValue previousRSI, Lib.Candlestick latestCandlestick) { if (null == latestCandlestick) { throw new ArgumentNullException("candlestick"); } return(CalculateNextValue(previousRSI, latestCandlestick.StartEndDifference)); }
public void OnlyStartEndPriceSet_propertiesSetHigherAndLowestPricesSetToMinAndMax() { var stick = new Lib.Candlestick(5M, 10M); Assert.Equal(5M, stick.StartPrice); Assert.Equal(10M, stick.EndPrice); Assert.Equal(10M, stick.HighestPrice); Assert.Equal(5M, stick.LowestPrice); }
public void DataSet_propertiesSet() { var stick = new Lib.Candlestick(5M, 10M, 12M, 4M); Assert.Equal(5M, stick.StartPrice); Assert.Equal(10M, stick.EndPrice); Assert.Equal(12M, stick.HighestPrice); Assert.Equal(4M, stick.LowestPrice); }
public void CandlesticksSet_RSIValueGetsCalculated() { var expected = new Lib.RSIValue(0.5848M, 0.5446M, 4); var candlesticks = new Lib.Candlestick[] { new Lib.Candlestick(10M, 11M), new Lib.Candlestick(11M, 10.3125M), new Lib.Candlestick(10.3125M, 10.8125M), new Lib.Candlestick(10.8125M, 8.8125M), new Lib.Candlestick(8.8125M, 8.125M), new Lib.Candlestick(8.125M, 8.5M), new Lib.Candlestick(8.5M, 9.625M), new Lib.Candlestick(9.625M, 11.6875M), new Lib.Candlestick(11.6875M, 11.4375M), new Lib.Candlestick(11.4375M, 10.875M), new Lib.Candlestick(10.875M, 8.4375M), new Lib.Candlestick(8.4375M, 10.1875M), new Lib.Candlestick(10.1875M, 11.5625M), new Lib.Candlestick(11.5625M, 10.5625M) }; var calculator = new Lib.RSICalculator(14); var actual = calculator.CalculateInitialValue(candlesticks); Assert.Equal(expected, actual); }
public void DataSet_startPriceHigherThanEndPrice_startEndDifferenceNegative() { var stick = new Lib.Candlestick(10M, 5M); Assert.Equal(-5M, stick.StartEndDifference); }
public void DataSet_startPriceLowerThanEndPrice_startEndDifferencePositive() { var stick = new Lib.Candlestick(5M, 10M); Assert.Equal(5M, stick.StartEndDifference); }