use of org.ta4j.core.Decimal in project ta4j by ta4j.
the class ThreeWhiteSoldiersIndicator method hasVeryShortUpperShadow.
/**
* @param index the bar/candle index
* @return true if the bar/candle has a very short upper shadow, false otherwise
*/
private boolean hasVeryShortUpperShadow(int index) {
Decimal currentUpperShadow = upperShadowInd.getValue(index);
// We use the black candle index to remove to bias of the previous soldiers
Decimal averageUpperShadow = averageUpperShadowInd.getValue(blackCandleIndex);
return currentUpperShadow.isLessThan(averageUpperShadow.multipliedBy(factor));
}
use of org.ta4j.core.Decimal in project ta4j by ta4j.
the class UpperShadowIndicator method calculate.
@Override
protected Decimal calculate(int index) {
Bar t = series.getBar(index);
final Decimal openPrice = t.getOpenPrice();
final Decimal closePrice = t.getClosePrice();
if (closePrice.isGreaterThan(openPrice)) {
// Bullish
return t.getMaxPrice().minus(closePrice);
} else {
// Bearish
return t.getMaxPrice().minus(openPrice);
}
}
use of org.ta4j.core.Decimal in project ta4j by ta4j.
the class ConvergenceDivergenceIndicator method calculatePositiveConvergence.
/**
* @param index the actual index
* @return true, if positive convergent
*/
private Boolean calculatePositiveConvergence(int index) {
CorrelationCoefficientIndicator cc = new CorrelationCoefficientIndicator(ref, other, timeFrame);
boolean isConvergent = cc.getValue(index).isGreaterThanOrEqual(minStrenght);
Decimal slope = calculateSlopeRel(index);
boolean isPositive = slope.isGreaterThanOrEqual(minSlope.abs());
return isConvergent && isPositive;
}
use of org.ta4j.core.Decimal in project ta4j by ta4j.
the class ConvergenceDivergenceIndicator method calculatePositiveDivergence.
/**
* @param index the actual index
* @return true, if positive divergent
*/
private Boolean calculatePositiveDivergence(int index) {
CorrelationCoefficientIndicator cc = new CorrelationCoefficientIndicator(ref, other, timeFrame);
boolean isDivergent = cc.getValue(index).isLessThanOrEqual(minStrenght.multipliedBy(Decimal.valueOf(-1)));
if (isDivergent) {
// If "isDivergent" and "ref" is positive, then "other" must be negative.
Decimal slope = calculateSlopeRel(index);
return slope.isGreaterThanOrEqual(minSlope.abs());
}
return false;
}
use of org.ta4j.core.Decimal in project ta4j by ta4j.
the class AccumulationDistributionIndicator method calculate.
@Override
protected Decimal calculate(int index) {
if (index == 0) {
return Decimal.ZERO;
}
// Calculating the money flow multiplier
Decimal moneyFlowMultiplier = clvIndicator.getValue(index);
// Calculating the money flow volume
Decimal moneyFlowVolume = moneyFlowMultiplier.multipliedBy(series.getBar(index).getVolume());
return moneyFlowVolume.plus(getValue(index - 1));
}
Aggregations