use of org.ta4j.core.indicators.CCIIndicator 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