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