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;
}
Aggregations