CCIStrategy

Commodity Channel Index Strategy is a strategy build to gain profit on buying and selling shares. CCI Strategy calculates one line of values:

  • CCI line - a function of a price, its mean deviation and simple moving average. Moreover it is dependent of user defined parameter a mean deviation impact.

In the moment when the CCI line crosses the oversold or overbought level from the proper side it is a signal for a strategy to make an order.

Strategy settings

CCI Strategy parameters
NUMBER OF PERIODS Number of trades included in moving averages computation
OVERSOLD LEVEL Defines oversold level for an asset
OVERBOUGHT LEVEL Defines overbought level for an asset
MEAN DEVIATION IMPACT Decides about importance of a standard deviation value

Case scenario

For case scenario CCI Strategy is set to default values and is executed on daily tick data.

CCI Example view

If the CCI index crosses from the top the overbought line it is a signal for the strategy to make a sell order. If the CCI index crosses from the bottom the oversold line it is a signal for the CCI Strategy to make a buy order.

CCI Strategy statistics

As can be seen in strategy statistics, CCI Strategy brought net profit of $11.440.

Development

CCI Strategy is composed of one trading action.

action(tradingAction
    .condition(TRADE_SIGNAL)
    .actionType(TradingActionType.NEW_ORDER)
    .createOrderWith(
        orderBuilder
            .withSymbol(marketSymbol)
            .side(SIDE)
            .withPriceLimit(PRICE)
            .withQuantity((s) -> BigDecimal.ONE)))

Action when fired checks conditions if it should buy or sell shares in the moment. If one of conditions is fulfilled then trading action makes order with proper side and price.

Additionally in strategy instance there is ON_TRADE consumer that is executed with every incoming trade.

private Consumer<TradeEvent> ON_TRADE = new Consumer<TradeEvent>() {
            @Override
            public void accept(TradeEvent tradeEvent) {
                    cci.add(tradeEvent.getPrice());

                    if (cci.isReady()) {
                            triggerTradingActions(tradeEvent.getMarketSymbol());
                    }
            }
    };

With every trade strategy recalculates stored average values and when proper number of trades pass it starts triggering defined trading action.