use of org.ta4j.core.trading.rules.UnderIndicatorRule 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;
}
use of org.ta4j.core.trading.rules.UnderIndicatorRule in project ta4j by ta4j.
the class TradingBotOnMovingTimeSeries method buildStrategy.
/**
* @param series a time series
* @return a dummy strategy
*/
private static Strategy buildStrategy(TimeSeries series) {
if (series == null) {
throw new IllegalArgumentException("Series cannot be null");
}
ClosePriceIndicator closePrice = new ClosePriceIndicator(series);
SMAIndicator sma = new SMAIndicator(closePrice, 12);
// Sell when close price goes over SMA
return new BaseStrategy(new OverIndicatorRule(sma, closePrice), new UnderIndicatorRule(sma, closePrice));
}
use of org.ta4j.core.trading.rules.UnderIndicatorRule in project ta4j by ta4j.
the class CCICorrectionStrategy method buildStrategy.
/**
* @param series a time series
* @return a CCI correction strategy
*/
public static Strategy buildStrategy(TimeSeries series) {
if (series == null) {
throw new IllegalArgumentException("Series cannot be null");
}
CCIIndicator longCci = new CCIIndicator(series, 200);
CCIIndicator shortCci = new CCIIndicator(series, 5);
Decimal plus100 = Decimal.HUNDRED;
Decimal minus100 = Decimal.valueOf(-100);
Rule entryRule = // Bull trend
new OverIndicatorRule(longCci, plus100).and(// Signal
new UnderIndicatorRule(shortCci, minus100));
Rule exitRule = // Bear trend
new UnderIndicatorRule(longCci, minus100).and(// Signal
new OverIndicatorRule(shortCci, plus100));
Strategy strategy = new BaseStrategy(entryRule, exitRule);
strategy.setUnstablePeriod(5);
return strategy;
}
Aggregations