use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class RSIIndicatorTest method firstValueShouldBeZero.
@Test
public void firstValueShouldBeZero() throws Exception {
Indicator<Decimal> indicator = getIndicator(new ClosePriceIndicator(data), 14);
assertEquals(Decimal.ZERO, indicator.getValue(0));
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class SMAIndicatorTest method usingTimeFrame3UsingClosePrice.
@Test
public void usingTimeFrame3UsingClosePrice() throws Exception {
Indicator<Decimal> indicator = getIndicator(new ClosePriceIndicator(data), 3);
assertDecimalEquals(indicator.getValue(0), 1);
assertDecimalEquals(indicator.getValue(1), 1.5);
assertDecimalEquals(indicator.getValue(2), 2);
assertDecimalEquals(indicator.getValue(3), 3);
assertDecimalEquals(indicator.getValue(4), 10d / 3);
assertDecimalEquals(indicator.getValue(5), 11d / 3);
assertDecimalEquals(indicator.getValue(6), 4);
assertDecimalEquals(indicator.getValue(7), 13d / 3);
assertDecimalEquals(indicator.getValue(8), 4);
assertDecimalEquals(indicator.getValue(9), 10d / 3);
assertDecimalEquals(indicator.getValue(10), 10d / 3);
assertDecimalEquals(indicator.getValue(11), 10d / 3);
assertDecimalEquals(indicator.getValue(12), 3);
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class TripleEMAIndicatorTest method setUp.
@Before
public void setUp() {
TimeSeries data = new MockTimeSeries(0.73, 0.72, 0.86, 0.72, 0.62, 0.76, 0.84, 0.69, 0.65, 0.71, 0.53, 0.73, 0.77, 0.67, 0.68);
closePrice = new ClosePriceIndicator(data);
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class UlcerIndexIndicatorTest method ulcerIndexUsingTimeFrame14UsingIBMData.
@Test
public void ulcerIndexUsingTimeFrame14UsingIBMData() {
UlcerIndexIndicator ulcer = new UlcerIndexIndicator(new ClosePriceIndicator(ibmData), 14);
assertDecimalEquals(ulcer.getValue(0), 0);
// From: http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:ulcer_index
assertDecimalEquals(ulcer.getValue(26), 1.3047);
assertDecimalEquals(ulcer.getValue(27), 1.3022);
assertDecimalEquals(ulcer.getValue(28), 1.2156);
assertDecimalEquals(ulcer.getValue(29), 0.9967);
assertDecimalEquals(ulcer.getValue(30), 0.7257);
assertDecimalEquals(ulcer.getValue(31), 0.453);
assertDecimalEquals(ulcer.getValue(32), 0.4284);
assertDecimalEquals(ulcer.getValue(33), 0.4284);
assertDecimalEquals(ulcer.getValue(34), 0.4284);
assertDecimalEquals(ulcer.getValue(35), 0.4287);
assertDecimalEquals(ulcer.getValue(36), 0.5089);
assertDecimalEquals(ulcer.getValue(37), 0.6673);
assertDecimalEquals(ulcer.getValue(38), 0.9914);
assertDecimalEquals(ulcer.getValue(39), 1.0921);
assertDecimalEquals(ulcer.getValue(40), 1.3161);
assertDecimalEquals(ulcer.getValue(41), 1.5632);
assertDecimalEquals(ulcer.getValue(42), 1.7609);
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class WMAIndicatorTest method calculate.
@Test
public void calculate() {
MockTimeSeries series = new MockTimeSeries(1d, 2d, 3d, 4d, 5d, 6d);
Indicator<Decimal> close = new ClosePriceIndicator(series);
Indicator<Decimal> wmaIndicator = new WMAIndicator(close, 3);
assertDecimalEquals(wmaIndicator.getValue(0), 1);
assertDecimalEquals(wmaIndicator.getValue(1), 1.6667);
assertDecimalEquals(wmaIndicator.getValue(2), 2.3333);
assertDecimalEquals(wmaIndicator.getValue(3), 3.3333);
assertDecimalEquals(wmaIndicator.getValue(4), 4.3333);
assertDecimalEquals(wmaIndicator.getValue(5), 5.3333);
}
Aggregations