Search in sources :

Example 1 with DifferenceIndicator

use of org.ta4j.core.indicators.helpers.DifferenceIndicator in project ta4j by ta4j.

the class InSlopeRule method isSatisfied.

@Override
public boolean isSatisfied(int index, TradingRecord tradingRecord) {
    DifferenceIndicator diff = new DifferenceIndicator(ref, prev);
    Decimal val = diff.getValue(index);
    boolean minSlopeSatisfied = minSlope.isNaN() || val.isGreaterThanOrEqual(minSlope);
    boolean maxSlopeSatisfied = maxSlope.isNaN() || val.isLessThanOrEqual(maxSlope);
    boolean isNaN = minSlope.isNaN() && maxSlope.isNaN();
    final boolean satisfied = minSlopeSatisfied && maxSlopeSatisfied && !isNaN;
    traceIsSatisfied(index, satisfied);
    return satisfied;
}
Also used : Decimal(org.ta4j.core.Decimal) DifferenceIndicator(org.ta4j.core.indicators.helpers.DifferenceIndicator)

Aggregations

Decimal (org.ta4j.core.Decimal)1 DifferenceIndicator (org.ta4j.core.indicators.helpers.DifferenceIndicator)1