Search in sources :

Example 41 with ClosePriceIndicator

use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.

the class MMAIndicatorTest method mmaUsingTimeFrame10UsingClosePrice.

@Test
public void mmaUsingTimeFrame10UsingClosePrice() throws Exception {
    Indicator<Decimal> actualIndicator = getIndicator(new ClosePriceIndicator(data), 10);
    assertEquals(63.9983, actualIndicator.getValue(9).doubleValue(), TATestsUtils.TA_OFFSET);
    assertEquals(63.7315, actualIndicator.getValue(10).doubleValue(), TATestsUtils.TA_OFFSET);
    assertEquals(63.5093, actualIndicator.getValue(11).doubleValue(), TATestsUtils.TA_OFFSET);
}
Also used : ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Test(org.junit.Test)

Example 42 with ClosePriceIndicator

use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.

the class MMAIndicatorTest method firstValueShouldBeEqualsToFirstDataValue.

@Test
public void firstValueShouldBeEqualsToFirstDataValue() throws Exception {
    Indicator<Decimal> actualIndicator = getIndicator(new ClosePriceIndicator(data), 1);
    assertEquals(64.75, actualIndicator.getValue(0).doubleValue(), TATestsUtils.TA_OFFSET);
}
Also used : ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Test(org.junit.Test)

Example 43 with ClosePriceIndicator

use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.

the class RAVIIndicatorTest method ravi.

@Test
public void ravi() {
    ClosePriceIndicator closePrice = new ClosePriceIndicator(data);
    RAVIIndicator ravi = new RAVIIndicator(closePrice, 3, 8);
    assertDecimalEquals(ravi.getValue(0), 0);
    assertDecimalEquals(ravi.getValue(1), 0);
    assertDecimalEquals(ravi.getValue(2), 0);
    assertDecimalEquals(ravi.getValue(3), -0.6937);
    assertDecimalEquals(ravi.getValue(4), -1.1411);
    assertDecimalEquals(ravi.getValue(5), -0.1577);
    assertDecimalEquals(ravi.getValue(6), 0.229);
    assertDecimalEquals(ravi.getValue(7), 0.2412);
    assertDecimalEquals(ravi.getValue(8), 0.1202);
    assertDecimalEquals(ravi.getValue(9), -0.3324);
    assertDecimalEquals(ravi.getValue(10), -0.5804);
    assertDecimalEquals(ravi.getValue(11), 0.2013);
    assertDecimalEquals(ravi.getValue(12), 1.6156);
    assertDecimalEquals(ravi.getValue(13), 2.6167);
    assertDecimalEquals(ravi.getValue(14), 4.0799);
}
Also used : ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Test(org.junit.Test)

Example 44 with ClosePriceIndicator

use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.

the class PercentBIndicatorTest 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);
}
Also used : TimeSeries(org.ta4j.core.TimeSeries) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Before(org.junit.Before)

Example 45 with ClosePriceIndicator

use of org.ta4j.core.indicators.helpers.ClosePriceIndicator in project ta4j by ta4j.

the class RSIIndicatorTest method hundredIfNoLoss.

@Test
public void hundredIfNoLoss() throws Exception {
    Indicator<Decimal> indicator = getIndicator(new ClosePriceIndicator(data), 1);
    assertEquals(Decimal.HUNDRED, indicator.getValue(14));
    assertEquals(Decimal.HUNDRED, indicator.getValue(15));
}
Also used : ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Test(org.junit.Test)

Aggregations

ClosePriceIndicator (org.ta4j.core.indicators.helpers.ClosePriceIndicator)81 Test (org.junit.Test)55 MockTimeSeries (org.ta4j.core.mocks.MockTimeSeries)26 TimeSeries (org.ta4j.core.TimeSeries)16 Before (org.junit.Before)14 SMAIndicator (org.ta4j.core.indicators.SMAIndicator)7 OverIndicatorRule (org.ta4j.core.trading.rules.OverIndicatorRule)6 ArrayList (java.util.ArrayList)5 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)5 MockBar (org.ta4j.core.mocks.MockBar)5 UnderIndicatorRule (org.ta4j.core.trading.rules.UnderIndicatorRule)5 SimpleDateFormat (java.text.SimpleDateFormat)4 JFreeChart (org.jfree.chart.JFreeChart)4 DateAxis (org.jfree.chart.axis.DateAxis)4 XYPlot (org.jfree.chart.plot.XYPlot)4 EMAIndicator (org.ta4j.core.indicators.EMAIndicator)4 CrossedDownIndicatorRule (org.ta4j.core.trading.rules.CrossedDownIndicatorRule)4 BaseStrategy (org.ta4j.core.BaseStrategy)3 Decimal (org.ta4j.core.Decimal)3 MaxPriceIndicator (org.ta4j.core.indicators.helpers.MaxPriceIndicator)3