Search in sources :

Example 66 with ClosePriceIndicator

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

the class BollingerBandsLowerIndicatorTest 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);
}
Also used : SMAIndicator(org.ta4j.core.indicators.SMAIndicator) 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 67 with ClosePriceIndicator

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

the class MeanDeviationIndicatorTest method meanDeviationUsingTimeFrame5UsingClosePrice.

@Test
public void meanDeviationUsingTimeFrame5UsingClosePrice() {
    MeanDeviationIndicator meanDeviation = new MeanDeviationIndicator(new ClosePriceIndicator(data), 5);
    assertDecimalEquals(meanDeviation.getValue(2), 2.44444444444444);
    assertDecimalEquals(meanDeviation.getValue(3), 2.5);
    assertDecimalEquals(meanDeviation.getValue(7), 2.16);
    assertDecimalEquals(meanDeviation.getValue(8), 2.32);
    assertDecimalEquals(meanDeviation.getValue(9), 2.72);
}
Also used : ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Test(org.junit.Test)

Example 68 with ClosePriceIndicator

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

the class MeanDeviationIndicatorTest method firstValueShouldBeZero.

@Test
public void firstValueShouldBeZero() {
    MeanDeviationIndicator meanDeviation = new MeanDeviationIndicator(new ClosePriceIndicator(data), 5);
    assertDecimalEquals(meanDeviation.getValue(0), 0);
}
Also used : ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Test(org.junit.Test)

Example 69 with ClosePriceIndicator

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

the class PeriodicalGrowthRateIndicatorTest method setUp.

@Before
public void setUp() {
    TimeSeries mockSeries = new MockTimeSeries(29.49, 28.30, 27.74, 27.65, 27.60, 28.70, 28.60, 28.19, 27.40, 27.20, 27.28, 27.00, 27.59, 26.20, 25.75, 24.75, 23.33, 24.45, 24.25, 25.02, 23.60, 24.20, 24.28, 25.70, 25.46, 25.10, 25.00, 25.00, 25.85);
    seriesManager = new TimeSeriesManager(mockSeries);
    closePrice = new ClosePriceIndicator(mockSeries);
}
Also used : MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Before(org.junit.Before)

Example 70 with ClosePriceIndicator

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

the class SimpleLinearRegressionIndicatorTest method calculateLinearRegression.

@Test
public void calculateLinearRegression() {
    double[] values = new double[] { 1, 2, 1.3, 3.75, 2.25 };
    ClosePriceIndicator indicator = new ClosePriceIndicator(new MockTimeSeries(values));
    SimpleLinearRegressionIndicator reg = new SimpleLinearRegressionIndicator(indicator, 5);
    SimpleRegression origReg = buildSimpleRegression(values);
    assertDecimalEquals(reg.getValue(4), origReg.predict(4));
}
Also used : SimpleRegression(org.apache.commons.math3.stat.regression.SimpleRegression) MockTimeSeries(org.ta4j.core.mocks.MockTimeSeries) 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