use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class BollingerBandWidthIndicatorTest method setUp.
@Before
public void setUp() {
TimeSeries data = new MockTimeSeries(10, 12, 15, 14, 17, 20, 21, 20, 20, 19, 20, 17, 12, 12, 9, 8, 9, 10, 9, 10);
closePrice = new ClosePriceIndicator(data);
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class BollingerBandsMiddleIndicatorTest method bollingerBandsMiddleUsingSMA.
@Test
public void bollingerBandsMiddleUsingSMA() {
SMAIndicator sma = new SMAIndicator(new ClosePriceIndicator(data), 3);
BollingerBandsMiddleIndicator bbmSMA = new BollingerBandsMiddleIndicator(sma);
for (int i = 0; i < data.getBarCount(); i++) {
assertEquals(sma.getValue(i), bbmSMA.getValue(i));
}
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class BollingerBandsUpperIndicatorTest method setUp.
@Before
public void setUp() {
TimeSeries data = new MockTimeSeries(1, 2, 3, 4, 3, 4, 5, 4, 3, 3, 4, 3, 2);
timeFrame = 3;
closePrice = new ClosePriceIndicator(data);
sma = new SMAIndicator(closePrice, timeFrame);
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class KAMAIndicatorTest method kama.
@Test
public void kama() {
ClosePriceIndicator closePrice = new ClosePriceIndicator(data);
KAMAIndicator kama = new KAMAIndicator(closePrice, 10, 2, 30);
assertDecimalEquals(kama.getValue(9), 109.2400);
assertDecimalEquals(kama.getValue(10), 109.2449);
assertDecimalEquals(kama.getValue(11), 109.2165);
assertDecimalEquals(kama.getValue(12), 109.1173);
assertDecimalEquals(kama.getValue(13), 109.0981);
assertDecimalEquals(kama.getValue(14), 109.0894);
assertDecimalEquals(kama.getValue(15), 109.1240);
assertDecimalEquals(kama.getValue(16), 109.1376);
assertDecimalEquals(kama.getValue(17), 109.2769);
assertDecimalEquals(kama.getValue(18), 109.4365);
assertDecimalEquals(kama.getValue(19), 109.4569);
assertDecimalEquals(kama.getValue(20), 109.4651);
assertDecimalEquals(kama.getValue(21), 109.4612);
assertDecimalEquals(kama.getValue(22), 109.3904);
assertDecimalEquals(kama.getValue(23), 109.3165);
assertDecimalEquals(kama.getValue(24), 109.2924);
assertDecimalEquals(kama.getValue(25), 109.1836);
assertDecimalEquals(kama.getValue(26), 109.0778);
assertDecimalEquals(kama.getValue(27), 108.9498);
assertDecimalEquals(kama.getValue(28), 108.4230);
assertDecimalEquals(kama.getValue(29), 108.0157);
assertDecimalEquals(kama.getValue(30), 107.9967);
assertDecimalEquals(kama.getValue(31), 108.0069);
assertDecimalEquals(kama.getValue(32), 108.2596);
assertDecimalEquals(kama.getValue(33), 108.4818);
assertDecimalEquals(kama.getValue(34), 108.9119);
assertDecimalEquals(kama.getValue(35), 109.6734);
assertDecimalEquals(kama.getValue(36), 110.4947);
assertDecimalEquals(kama.getValue(37), 111.1077);
assertDecimalEquals(kama.getValue(38), 111.4622);
assertDecimalEquals(kama.getValue(39), 111.6092);
assertDecimalEquals(kama.getValue(40), 111.5663);
assertDecimalEquals(kama.getValue(41), 111.5491);
assertDecimalEquals(kama.getValue(42), 111.5425);
assertDecimalEquals(kama.getValue(43), 111.5426);
assertDecimalEquals(kama.getValue(44), 111.5457);
assertDecimalEquals(kama.getValue(45), 111.5658);
assertDecimalEquals(kama.getValue(46), 111.5688);
assertDecimalEquals(kama.getValue(47), 111.5522);
assertDecimalEquals(kama.getValue(48), 111.5595);
}
use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.
the class KAMAIndicatorTest method getValueOnDeepIndicesShouldNotCauseStackOverflow.
@Test
public void getValueOnDeepIndicesShouldNotCauseStackOverflow() {
TimeSeries series = new MockTimeSeries();
series.setMaximumBarCount(5000);
assertEquals(5000, series.getBarCount());
KAMAIndicator kama = new KAMAIndicator(new ClosePriceIndicator(series), 10, 2, 30);
try {
assertDecimalEquals(kama.getValue(3000), "2999.75");
} catch (Throwable t) {
fail(t.getMessage());
}
}
Aggregations