use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class HMAIndicatorTest method hmaUsingTimeFrame9UsingClosePrice.
@Test
public void hmaUsingTimeFrame9UsingClosePrice() {
// Example from http://traders.com/Documentation/FEEDbk_docs/2010/12/TradingIndexesWithHullMA.xls
HMAIndicator hma = new HMAIndicator(new ClosePriceIndicator(data), 9);
assertDecimalEquals(hma.getValue(10), 86.3204);
assertDecimalEquals(hma.getValue(11), 85.3705);
assertDecimalEquals(hma.getValue(12), 84.1044);
assertDecimalEquals(hma.getValue(13), 83.0197);
assertDecimalEquals(hma.getValue(14), 81.3913);
assertDecimalEquals(hma.getValue(15), 79.6511);
assertDecimalEquals(hma.getValue(16), 78.0443);
assertDecimalEquals(hma.getValue(17), 76.8832);
assertDecimalEquals(hma.getValue(18), 75.5363);
assertDecimalEquals(hma.getValue(19), 75.1713);
assertDecimalEquals(hma.getValue(20), 75.3597);
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class MMAIndicatorTest method stackOverflowError.
@Test
public void stackOverflowError() throws Exception {
List<Bar> bigListOfBars = new ArrayList<>();
for (int i = 0; i < 10000; i++) {
bigListOfBars.add(new MockBar(i));
}
MockTimeSeries bigSeries = new MockTimeSeries(bigListOfBars);
ClosePriceIndicator closePrice = new ClosePriceIndicator(bigSeries);
Indicator<Decimal> actualIndicator = getIndicator(closePrice, 10);
// if a StackOverflowError is thrown here, then the RecursiveCachedIndicator does not work as intended.
assertEquals(9990.0, actualIndicator.getValue(9999).doubleValue(), TATestsUtils.TA_OFFSET);
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class PPOIndicatorTest method setUp.
@Before
public void setUp() {
TimeSeries series = new MockTimeSeries(22.27, 22.19, 22.08, 22.17, 22.18, 22.13, 22.23, 22.43, 22.24, 22.29, 22.15, 22.39, 22.38, 22.61, 23.36, 24.05, 23.75, 23.83, 23.95, 23.63, 23.82, 23.87, 23.65, 23.19, 23.10, 23.33, 22.68, 23.10, 21.40, 20.17);
closePriceIndicator = new ClosePriceIndicator(series);
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class ZLEMAIndicatorTest method valuesLessThanTimeFrameMustBeEqualsToSMAValues.
@Test
public void valuesLessThanTimeFrameMustBeEqualsToSMAValues() {
ZLEMAIndicator zlema = new ZLEMAIndicator(new ClosePriceIndicator(data), 10);
SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(data), 10);
for (int i = 0; i < 9; i++) {
assertEquals(sma.getValue(i), zlema.getValue(i));
}
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class ZLEMAIndicatorTest method ZLEMAFirstValueShouldBeEqualsToFirstDataValue.
@Test
public void ZLEMAFirstValueShouldBeEqualsToFirstDataValue() {
ZLEMAIndicator zlema = new ZLEMAIndicator(new ClosePriceIndicator(data), 10);
assertDecimalEquals(zlema.getValue(0), "10");
}
Aggregations