Search in sources :

Example 1 with AndRule

use of org.ta4j.core.trading.rules.AndRule 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)

Aggregations

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