use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class WMAIndicatorTest method wmaUsingTimeFrame9UsingClosePrice.
@Test
public void wmaUsingTimeFrame9UsingClosePrice() {
// Example from http://traders.com/Documentation/FEEDbk_docs/2010/12/TradingIndexesWithHullMA.xls
TimeSeries data = new MockTimeSeries(84.53, 87.39, 84.55, 82.83, 82.58, 83.74, 83.33, 84.57, 86.98, 87.10, 83.11, 83.60, 83.66, 82.76, 79.22, 79.03, 78.18, 77.42, 74.65, 77.48, 76.87);
WMAIndicator wma = new WMAIndicator(new ClosePriceIndicator(data), 9);
assertDecimalEquals(wma.getValue(8), 84.4958);
assertDecimalEquals(wma.getValue(9), 85.0158);
assertDecimalEquals(wma.getValue(10), 84.6807);
assertDecimalEquals(wma.getValue(11), 84.5387);
assertDecimalEquals(wma.getValue(12), 84.4298);
assertDecimalEquals(wma.getValue(13), 84.1224);
assertDecimalEquals(wma.getValue(14), 83.1031);
assertDecimalEquals(wma.getValue(15), 82.1462);
assertDecimalEquals(wma.getValue(16), 81.1149);
assertDecimalEquals(wma.getValue(17), 80.0736);
assertDecimalEquals(wma.getValue(18), 78.6907);
assertDecimalEquals(wma.getValue(19), 78.1504);
assertDecimalEquals(wma.getValue(20), 77.6133);
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class WilliamsRIndicatorTest method williamsRUsingTimeFrame10UsingClosePrice.
@Test
public void williamsRUsingTimeFrame10UsingClosePrice() {
WilliamsRIndicator wr = new WilliamsRIndicator(new ClosePriceIndicator(data), 10, new MaxPriceIndicator(data), new MinPriceIndicator(data));
assertDecimalEquals(wr.getValue(9), -4.0816);
assertDecimalEquals(wr.getValue(10), -11.7647);
assertDecimalEquals(wr.getValue(11), -8.9286);
assertDecimalEquals(wr.getValue(12), -10.5263);
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class WilliamsRIndicatorTest method valueLessThenTimeFrame.
@Test
public void valueLessThenTimeFrame() {
WilliamsRIndicator wr = new WilliamsRIndicator(new ClosePriceIndicator(data), 100, new MaxPriceIndicator(data), new MinPriceIndicator(data));
assertDecimalEquals(wr.getValue(0), -100d * (0.12 / 0.21));
assertDecimalEquals(wr.getValue(1), -100d * (0.07 / 0.21));
assertDecimalEquals(wr.getValue(2), -100d * (0.13 / 0.36));
assertDecimalEquals(wr.getValue(3), -100d * (0.18 / 0.36));
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class CMOIndicatorTest method dpo.
@Test
public void dpo() {
CMOIndicator cmo = new CMOIndicator(new ClosePriceIndicator(series), 9);
assertDecimalEquals(cmo.getValue(5), 85.1351);
assertDecimalEquals(cmo.getValue(6), 53.9326);
assertDecimalEquals(cmo.getValue(7), 6.2016);
assertDecimalEquals(cmo.getValue(8), -1.083);
assertDecimalEquals(cmo.getValue(9), 0.7092);
assertDecimalEquals(cmo.getValue(10), -1.4493);
assertDecimalEquals(cmo.getValue(11), 10.7266);
assertDecimalEquals(cmo.getValue(12), -3.5857);
assertDecimalEquals(cmo.getValue(13), 4.7619);
assertDecimalEquals(cmo.getValue(14), 24.1983);
assertDecimalEquals(cmo.getValue(15), 47.644);
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class CachedIndicatorTest method getValueWithCacheLengthIncrease.
@Test
public void getValueWithCacheLengthIncrease() {
double[] data = new double[200];
Arrays.fill(data, 10);
SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(new MockTimeSeries(data)), 100);
assertDecimalEquals(sma.getValue(105), 10);
}
Aggregations