Search in sources :

Example 61 with ClosePriceIndicator

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);
}
Also used : ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Test(org.junit.Test)

Example 62 with ClosePriceIndicator

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);
}
Also used : MockBar(org.ta4j.core.mocks.MockBar) MockBar(org.ta4j.core.mocks.MockBar) ArrayList(java.util.ArrayList) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Test(org.junit.Test)

Example 63 with ClosePriceIndicator

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);
}
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 64 with ClosePriceIndicator

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));
    }
}
Also used : ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Test(org.junit.Test)

Example 65 with ClosePriceIndicator

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");
}
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