use of org.ta4j.core.Rule in project crypto-bot by jnidzwetzki.
the class BBreakoutStrategy method getStrategy.
public Strategy getStrategy() {
final ClosePriceIndicator closePrice = new ClosePriceIndicator(timeSeries);
final SMAIndicator sma = new SMAIndicator(closePrice, bbPeriod);
final BollingerBandsMiddleIndicator bbmiddle = new BollingerBandsMiddleIndicator(sma);
final StandardDeviationIndicator sd = new StandardDeviationIndicator(closePrice, bbPeriod);
final BollingerBandsUpperIndicator bbup = new BollingerBandsUpperIndicator(bbmiddle, sd, Decimal.valueOf(deviationUp));
final BollingerBandsUpperIndicator bbdown = new BollingerBandsUpperIndicator(bbmiddle, sd, Decimal.valueOf(deviationDown));
final Rule buyingRule = new UnderIndicatorRule(closePrice, bbdown);
final Rule sellingRule = new OverIndicatorRule(closePrice, bbup).or(new StopLossRule(closePrice, 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 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;
}
use of org.ta4j.core.Rule in project crypto-bot by jnidzwetzki.
the class EMAStrategy03 method getStrategy.
public Strategy getStrategy() {
ClosePriceIndicator closePrice = new ClosePriceIndicator(timeSeries);
EMAIndicator sma1 = new EMAIndicator(closePrice, sma1Value);
EMAIndicator sma2 = new EMAIndicator(closePrice, sma2Value);
EMAIndicator sma3 = new EMAIndicator(closePrice, sma3Value);
RSIIndicator rsi = new RSIIndicator(closePrice, 14);
Rule buyingRule = new OverIndicatorRule(sma1, sma2).and(new OverIndicatorRule(sma2, sma3)).and(new OverIndicatorRule(rsi, Decimal.valueOf(50)));
Rule sellingRule = new CrossedDownIndicatorRule(sma1, sma3).or(new CrossedDownIndicatorRule(sma2, sma3)).or(new StopLossRule(closePrice, Decimal.valueOf("3")));
final BaseStrategy strategy = new BaseStrategy(buyingRule, sellingRule);
return strategy;
}
use of org.ta4j.core.Rule in project ta4j by ta4j.
the class ConvergenceDivergenceIndicator method calculatePositiveDivergenceStrict.
/**
* @param index the actual index
* @return true, if positive divergent
*/
private Boolean calculatePositiveDivergenceStrict(int index) {
Rule refIsRising = new IsRisingRule(ref, timeFrame);
Rule otherIsFalling = new IsFallingRule(ref, timeFrame);
return (refIsRising.and(otherIsFalling)).isSatisfied(index);
}
use of org.ta4j.core.Rule in project ta4j by ta4j.
the class ConvergenceDivergenceIndicator method calculatePositiveConvergenceStrict.
/**
* @param index the actual index
* @return true, if strict positive convergent
*/
private Boolean calculatePositiveConvergenceStrict(int index) {
Rule refIsRising = new IsRisingRule(ref, timeFrame);
Rule otherIsRising = new IsRisingRule(ref, timeFrame);
return (refIsRising.and(otherIsRising)).isSatisfied(index);
}
Aggregations