Search in sources :

Example 1 with MinPriceIndicator

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

the class WilliamsRIndicatorTest method williamsRUsingTimeFrame5UsingClosePrice.

@Test
public void williamsRUsingTimeFrame5UsingClosePrice() {
    WilliamsRIndicator wr = new WilliamsRIndicator(new ClosePriceIndicator(data), 5, new MaxPriceIndicator(data), new MinPriceIndicator(data));
    assertDecimalEquals(wr.getValue(4), -47.2222);
    assertDecimalEquals(wr.getValue(5), -54.5454);
    assertDecimalEquals(wr.getValue(6), -78.5714);
    assertDecimalEquals(wr.getValue(7), -47.6190);
    assertDecimalEquals(wr.getValue(8), -25d);
    assertDecimalEquals(wr.getValue(9), -5.2632);
    assertDecimalEquals(wr.getValue(10), -13.9535);
}
Also used : MaxPriceIndicator(org.ta4j.core.indicators.helpers.MaxPriceIndicator) MinPriceIndicator(org.ta4j.core.indicators.helpers.MinPriceIndicator) ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Test(org.junit.Test)

Example 2 with MinPriceIndicator

use of org.ta4j.core.indicators.helpers.MinPriceIndicator in project crypto-bot by jnidzwetzki.

the class DonchianBot method getLowerChannelValue.

/**
 * Get the lower channel value
 * @param currencyPair
 * @return
 */
private Decimal getLowerChannelValue(final BitfinexCurrencyPair currencyPair) {
    final TimeSeries currencyTimeSeries = timeSeries.get(currencyPair);
    final MinPriceIndicator minPrice = new MinPriceIndicator(currencyTimeSeries);
    final DonchianChannelLower donchianChannelLower = new DonchianChannelLower(minPrice, periodOut);
    return donchianChannelLower.getValue(currencyTimeSeries.getEndIndex());
}
Also used : TimeSeries(org.ta4j.core.TimeSeries) DonchianChannelLower(com.github.jnidzwetzki.cryptobot.strategy.indicator.DonchianChannelLower) MinPriceIndicator(org.ta4j.core.indicators.helpers.MinPriceIndicator)

Example 3 with MinPriceIndicator

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

the class WilliamsRIndicatorTest method williamsRUsingTimeFrame10UsingClosePrice.

@Test
public void williamsRUsingTimeFrame10UsingClosePrice() {
    WilliamsRIndicator wr = new WilliamsRIndicator(new ClosePriceIndicator(data), 10, new MaxPriceIndicator(data), new MinPriceIndicator(data));
    assertDecimalEquals(wr.getValue(9), -4.0816);
    assertDecimalEquals(wr.getValue(10), -11.7647);
    assertDecimalEquals(wr.getValue(11), -8.9286);
    assertDecimalEquals(wr.getValue(12), -10.5263);
}
Also used : MaxPriceIndicator(org.ta4j.core.indicators.helpers.MaxPriceIndicator) MinPriceIndicator(org.ta4j.core.indicators.helpers.MinPriceIndicator) ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Test(org.junit.Test)

Example 4 with MinPriceIndicator

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

the class WilliamsRIndicatorTest method valueLessThenTimeFrame.

@Test
public void valueLessThenTimeFrame() {
    WilliamsRIndicator wr = new WilliamsRIndicator(new ClosePriceIndicator(data), 100, new MaxPriceIndicator(data), new MinPriceIndicator(data));
    assertDecimalEquals(wr.getValue(0), -100d * (0.12 / 0.21));
    assertDecimalEquals(wr.getValue(1), -100d * (0.07 / 0.21));
    assertDecimalEquals(wr.getValue(2), -100d * (0.13 / 0.36));
    assertDecimalEquals(wr.getValue(3), -100d * (0.18 / 0.36));
}
Also used : MaxPriceIndicator(org.ta4j.core.indicators.helpers.MaxPriceIndicator) MinPriceIndicator(org.ta4j.core.indicators.helpers.MinPriceIndicator) ClosePriceIndicator(org.ta4j.core.indicators.helpers.ClosePriceIndicator) Test(org.junit.Test)

Aggregations

MinPriceIndicator (org.ta4j.core.indicators.helpers.MinPriceIndicator)4 Test (org.junit.Test)3 ClosePriceIndicator (org.ta4j.core.indicators.helpers.ClosePriceIndicator)3 MaxPriceIndicator (org.ta4j.core.indicators.helpers.MaxPriceIndicator)3 DonchianChannelLower (com.github.jnidzwetzki.cryptobot.strategy.indicator.DonchianChannelLower)1 TimeSeries (org.ta4j.core.TimeSeries)1