Search in sources :

Example 1 with CorrelationCoefficientIndicator

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;
}
Also used : Decimal(org.ta4j.core.Decimal) CorrelationCoefficientIndicator(org.ta4j.core.indicators.statistics.CorrelationCoefficientIndicator)

Example 2 with CorrelationCoefficientIndicator

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;
}
Also used : Decimal(org.ta4j.core.Decimal) CorrelationCoefficientIndicator(org.ta4j.core.indicators.statistics.CorrelationCoefficientIndicator)

Example 3 with CorrelationCoefficientIndicator

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;
}
Also used : Decimal(org.ta4j.core.Decimal) CorrelationCoefficientIndicator(org.ta4j.core.indicators.statistics.CorrelationCoefficientIndicator)

Example 4 with CorrelationCoefficientIndicator

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;
}
Also used : Decimal(org.ta4j.core.Decimal) CorrelationCoefficientIndicator(org.ta4j.core.indicators.statistics.CorrelationCoefficientIndicator)

Aggregations

Decimal (org.ta4j.core.Decimal)4 CorrelationCoefficientIndicator (org.ta4j.core.indicators.statistics.CorrelationCoefficientIndicator)4