use of org.ta4j.core.Rule in project crypto-bot by jnidzwetzki.
the class EMAStrategy01 method getStrategy.
public Strategy getStrategy() {
SMAIndicator shortSma = new SMAIndicator(closePriceIndicator, 5);
SMAIndicator longSma = new SMAIndicator(closePriceIndicator, 30);
Rule buyingRule = new CrossedUpIndicatorRule(shortSma, longSma);
Rule sellingRule = new CrossedDownIndicatorRule(shortSma, longSma).or(new StopLossRule(closePriceIndicator, Decimal.valueOf("3"))).or(new StopGainRule(closePriceIndicator, Decimal.valueOf("2")));
final BaseStrategy strategy = new BaseStrategy(buyingRule, sellingRule);
return strategy;
}
use of org.ta4j.core.Rule in project crypto-bot by jnidzwetzki.
the class EMAStrategy02 method getStrategy.
public Strategy getStrategy() {
EMAIndicator sma1 = new EMAIndicator(closePriceIndicator, sma1Value);
EMAIndicator sma2 = new EMAIndicator(closePriceIndicator, sma2Value);
EMAIndicator sma3 = new EMAIndicator(closePriceIndicator, sma3Value);
Rule buyingRule = new CrossedUpIndicatorRule(sma1, sma2).and(new OverIndicatorRule(sma2, sma3));
Rule sellingRule = new CrossedDownIndicatorRule(sma1, sma3);
// .or(new CrossedDownIndicatorRule(sma2, sma3));
final BaseStrategy strategy = new BaseStrategy(buyingRule, sellingRule);
return strategy;
}
use of org.ta4j.core.Rule 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.Rule 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);
}
use of org.ta4j.core.Rule 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);
}
Aggregations