Search in sources :

Example 1 with MaxPriceIndicator

use of org.ta4j.core.indicators.helpers.MaxPriceIndicator 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 MaxPriceIndicator

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

the class DonchianBot method getUpperChannelValue.

/**
 * Get the upper channel value
 * @param currencyPair
 * @return
 */
private Decimal getUpperChannelValue(final BitfinexCurrencyPair currencyPair) {
    final TimeSeries currencyTimeSeries = timeSeries.get(currencyPair);
    final MaxPriceIndicator maxPrice = new MaxPriceIndicator(currencyTimeSeries);
    final DonchianChannelUpper donchianChannelUpper = new DonchianChannelUpper(maxPrice, periodIn);
    return donchianChannelUpper.getValue(currencyTimeSeries.getEndIndex());
}
Also used : MaxPriceIndicator(org.ta4j.core.indicators.helpers.MaxPriceIndicator) TimeSeries(org.ta4j.core.TimeSeries) DonchianChannelUpper(com.github.jnidzwetzki.cryptobot.strategy.indicator.DonchianChannelUpper)

Example 3 with MaxPriceIndicator

use of org.ta4j.core.indicators.helpers.MaxPriceIndicator 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 MaxPriceIndicator

use of org.ta4j.core.indicators.helpers.MaxPriceIndicator 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

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