use of org.ta4j.core.indicators.statistics.CorrelationCoefficientIndicator in project ta4j by ta4j.
the class ConvergenceDivergenceIndicator method calculateNegativeConvergence.
/**
* @param index the actual index
* @return true, if negative convergent
*/
private Boolean calculateNegativeConvergence(int index) {
CorrelationCoefficientIndicator cc = new CorrelationCoefficientIndicator(ref, other, timeFrame);
boolean isConvergent = cc.getValue(index).isGreaterThanOrEqual(minStrenght);
Decimal slope = calculateSlopeRel(index);
boolean isNegative = slope.isLessThanOrEqual(minSlope.abs().multipliedBy(Decimal.valueOf(-1)));
return isConvergent && isNegative;
}
use of org.ta4j.core.indicators.statistics.CorrelationCoefficientIndicator in project ta4j by ta4j.
the class ConvergenceDivergenceIndicator method calculateNegativeDivergence.
/**
* @param index the actual index
* @return true, if negative divergent
*/
private Boolean calculateNegativeDivergence(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.isLessThanOrEqual(minSlope.abs().multipliedBy(Decimal.valueOf(-1)));
}
return false;
}
use of org.ta4j.core.indicators.statistics.CorrelationCoefficientIndicator 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.indicators.statistics.CorrelationCoefficientIndicator 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;
}
Aggregations