Search in sources :

Example 1 with IsFallingRule

use of org.ta4j.core.trading.rules.IsFallingRule in project crypto-bot by jnidzwetzki.

the class DonchianChannelStrategy method getStrategy.

@Override
public Strategy getStrategy() {
    final MACDIndicator macd = new MACDIndicator(closePriceIndicator, 9, 26);
    final EMAIndicator emaMacd = new EMAIndicator(macd, 9);
    final Rule buyingRule = new AndRule(new IsRisingRule(donchianChannelUpper, 1), new OverIndicatorRule(macd, Decimal.valueOf(0)));
    final // new OrRule(
    Rule sellingRule = new IsFallingRule(donchianChannelLower, 1);
    // new UnderIndicatorRule(macd, emaMacd));
    final BaseStrategy strategy = new BaseStrategy(buyingRule, sellingRule);
    return strategy;
}
Also used : AndRule(org.ta4j.core.trading.rules.AndRule) OverIndicatorRule(org.ta4j.core.trading.rules.OverIndicatorRule) IsFallingRule(org.ta4j.core.trading.rules.IsFallingRule) EMAIndicator(org.ta4j.core.indicators.EMAIndicator) IsRisingRule(org.ta4j.core.trading.rules.IsRisingRule) MACDIndicator(org.ta4j.core.indicators.MACDIndicator) BaseStrategy(org.ta4j.core.BaseStrategy) Rule(org.ta4j.core.Rule) IsFallingRule(org.ta4j.core.trading.rules.IsFallingRule) OverIndicatorRule(org.ta4j.core.trading.rules.OverIndicatorRule) AndRule(org.ta4j.core.trading.rules.AndRule) IsRisingRule(org.ta4j.core.trading.rules.IsRisingRule)

Example 2 with IsFallingRule

use of org.ta4j.core.trading.rules.IsFallingRule in project ta4j by ta4j.

the class ConvergenceDivergenceIndicator method calculatePositiveDivergenceStrict.

/**
 * @param index the actual index
 * @return true, if positive divergent
 */
private Boolean calculatePositiveDivergenceStrict(int index) {
    Rule refIsRising = new IsRisingRule(ref, timeFrame);
    Rule otherIsFalling = new IsFallingRule(ref, timeFrame);
    return (refIsRising.and(otherIsFalling)).isSatisfied(index);
}
Also used : IsFallingRule(org.ta4j.core.trading.rules.IsFallingRule) IsRisingRule(org.ta4j.core.trading.rules.IsRisingRule) Rule(org.ta4j.core.Rule) IsFallingRule(org.ta4j.core.trading.rules.IsFallingRule) IsRisingRule(org.ta4j.core.trading.rules.IsRisingRule)

Example 3 with IsFallingRule

use of org.ta4j.core.trading.rules.IsFallingRule in project ta4j by ta4j.

the class ConvergenceDivergenceIndicator method calculateNegativeConvergenceStrict.

/**
 * @param index the actual index
 * @return true, if strict negative convergent
 */
private Boolean calculateNegativeConvergenceStrict(int index) {
    Rule refIsFalling = new IsFallingRule(ref, timeFrame);
    Rule otherIsFalling = new IsFallingRule(ref, timeFrame);
    return (refIsFalling.and(otherIsFalling)).isSatisfied(index);
}
Also used : IsFallingRule(org.ta4j.core.trading.rules.IsFallingRule) Rule(org.ta4j.core.Rule) IsFallingRule(org.ta4j.core.trading.rules.IsFallingRule) IsRisingRule(org.ta4j.core.trading.rules.IsRisingRule)

Example 4 with IsFallingRule

use of org.ta4j.core.trading.rules.IsFallingRule in project ta4j by ta4j.

the class ConvergenceDivergenceIndicator method calculateNegativeDivergenceStrict.

/**
 * @param index the actual index
 * @return true, if negative divergent
 */
private Boolean calculateNegativeDivergenceStrict(int index) {
    Rule refIsFalling = new IsFallingRule(ref, timeFrame);
    Rule otherIsRising = new IsRisingRule(ref, timeFrame);
    return (refIsFalling.and(otherIsRising)).isSatisfied(index);
}
Also used : IsFallingRule(org.ta4j.core.trading.rules.IsFallingRule) IsRisingRule(org.ta4j.core.trading.rules.IsRisingRule) Rule(org.ta4j.core.Rule) IsFallingRule(org.ta4j.core.trading.rules.IsFallingRule) IsRisingRule(org.ta4j.core.trading.rules.IsRisingRule)

Aggregations

Rule (org.ta4j.core.Rule)4 IsFallingRule (org.ta4j.core.trading.rules.IsFallingRule)4 IsRisingRule (org.ta4j.core.trading.rules.IsRisingRule)4 BaseStrategy (org.ta4j.core.BaseStrategy)1 EMAIndicator (org.ta4j.core.indicators.EMAIndicator)1 MACDIndicator (org.ta4j.core.indicators.MACDIndicator)1 AndRule (org.ta4j.core.trading.rules.AndRule)1 OverIndicatorRule (org.ta4j.core.trading.rules.OverIndicatorRule)1