Search in sources :

Example 1 with StochasticOscillatorDIndicator

use of org.ta4j.core.indicators.StochasticOscillatorDIndicator in project crypto-bot by jnidzwetzki.

the class ForexStrategy01 method getStrategy.

public Strategy getStrategy() {
    EMAIndicator sma1 = new EMAIndicator(closePriceIndicator, 5);
    EMAIndicator sma2 = new EMAIndicator(closePriceIndicator, 10);
    RSIIndicator rsi = new RSIIndicator(closePriceIndicator, 14);
    StochasticOscillatorKIndicator stochK = new StochasticOscillatorKIndicator(timeSeries, 14);
    StochasticOscillatorDIndicator stochD = new StochasticOscillatorDIndicator(stochK);
    Rule buyingRule = new CrossedUpIndicatorRule(sma1, sma2).and(new OverIndicatorRule(rsi, Decimal.valueOf(50))).and(new OverIndicatorRule(stochK, stochD)).and(new UnderIndicatorRule(stochD, Decimal.valueOf(80)));
    Rule sellingRule = new CrossedDownIndicatorRule(sma1, sma2).or(new CrossedDownIndicatorRule(rsi, Decimal.valueOf(50)));
    final BaseStrategy strategy = new BaseStrategy(buyingRule, sellingRule);
    return strategy;
}
Also used : StochasticOscillatorDIndicator(org.ta4j.core.indicators.StochasticOscillatorDIndicator) OverIndicatorRule(org.ta4j.core.trading.rules.OverIndicatorRule) EMAIndicator(org.ta4j.core.indicators.EMAIndicator) UnderIndicatorRule(org.ta4j.core.trading.rules.UnderIndicatorRule) CrossedUpIndicatorRule(org.ta4j.core.trading.rules.CrossedUpIndicatorRule) CrossedDownIndicatorRule(org.ta4j.core.trading.rules.CrossedDownIndicatorRule) RSIIndicator(org.ta4j.core.indicators.RSIIndicator) BaseStrategy(org.ta4j.core.BaseStrategy) StochasticOscillatorKIndicator(org.ta4j.core.indicators.StochasticOscillatorKIndicator) Rule(org.ta4j.core.Rule) OverIndicatorRule(org.ta4j.core.trading.rules.OverIndicatorRule) UnderIndicatorRule(org.ta4j.core.trading.rules.UnderIndicatorRule) CrossedDownIndicatorRule(org.ta4j.core.trading.rules.CrossedDownIndicatorRule) CrossedUpIndicatorRule(org.ta4j.core.trading.rules.CrossedUpIndicatorRule)

Aggregations

BaseStrategy (org.ta4j.core.BaseStrategy)1 Rule (org.ta4j.core.Rule)1 EMAIndicator (org.ta4j.core.indicators.EMAIndicator)1 RSIIndicator (org.ta4j.core.indicators.RSIIndicator)1 StochasticOscillatorDIndicator (org.ta4j.core.indicators.StochasticOscillatorDIndicator)1 StochasticOscillatorKIndicator (org.ta4j.core.indicators.StochasticOscillatorKIndicator)1 CrossedDownIndicatorRule (org.ta4j.core.trading.rules.CrossedDownIndicatorRule)1 CrossedUpIndicatorRule (org.ta4j.core.trading.rules.CrossedUpIndicatorRule)1 OverIndicatorRule (org.ta4j.core.trading.rules.OverIndicatorRule)1 UnderIndicatorRule (org.ta4j.core.trading.rules.UnderIndicatorRule)1