Search in sources :

Example 76 with Decimal

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

Example 77 with Decimal

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

Example 78 with Decimal

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

Example 79 with Decimal

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

Example 80 with Decimal

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

Aggregations

Decimal (org.ta4j.core.Decimal)92 Bar (org.ta4j.core.Bar)20 Test (org.junit.Test)8 CorrelationCoefficientIndicator (org.ta4j.core.indicators.statistics.CorrelationCoefficientIndicator)4 Trade (org.ta4j.core.Trade)3 ClosePriceIndicator (org.ta4j.core.indicators.helpers.ClosePriceIndicator)3 Trade (com.github.jnidzwetzki.cryptobot.entity.Trade)2 CashFlow (org.ta4j.core.analysis.CashFlow)2 HighestValueIndicator (org.ta4j.core.indicators.helpers.HighestValueIndicator)2 LowestValueIndicator (org.ta4j.core.indicators.helpers.LowestValueIndicator)2 MockTimeSeries (org.ta4j.core.mocks.MockTimeSeries)2 DifferenceIndicator (org.ta4j.core.indicators.helpers.DifferenceIndicator)1