use of org.ta4j.core.Decimal in project ta4j by ta4j.
the class MinusDMIndicator method calculate.
@Override
protected Decimal calculate(int index) {
if (index == 0) {
return Decimal.ZERO;
}
Decimal upMove = series.getBar(index).getMaxPrice().minus(series.getBar(index - 1).getMaxPrice());
Decimal downMove = series.getBar(index - 1).getMinPrice().minus(series.getBar(index).getMinPrice());
if (downMove.isGreaterThan(upMove) && downMove.isGreaterThan(Decimal.ZERO)) {
return downMove;
} else {
return Decimal.ZERO;
}
}
use of org.ta4j.core.Decimal in project ta4j by ta4j.
the class TypicalPriceIndicatorTest method indicatorShouldRetrieveBarMaxPrice.
@Test
public void indicatorShouldRetrieveBarMaxPrice() {
for (int i = 0; i < 10; i++) {
Bar bar = timeSeries.getBar(i);
Decimal typicalPrice = bar.getMaxPrice().plus(bar.getMinPrice()).plus(bar.getClosePrice()).dividedBy(Decimal.THREE);
assertEquals(typicalPrice, typicalPriceIndicator.getValue(i));
}
}
Aggregations