A Simple and Efficient CCI Trading System

Commodity Channel Index (CCI) is an oscillator indicator which accurately identifies overbought or oversold levels. It was developed by Donald Lambert in 1980, and was originally supposed to be used exclusively for commodities trading, but later it found its application in Stocks and Futures as well.  CCI compares current price to the average price for a given time period. If the current price is greater than the average price CCI indicates Overbought condition, while if the current price is less than average price CCI indicates Oversold condition.  CCI value oscillates between two extremes, hence its is particularly useful for Mean reversion Trading systems. However CCI divergence can be used to identify trends too. In this post we’ll go through a very simple CCI Trading System. The results of this system is quite impressive and consistent when backtested on Daily timeframe.

Read our article on AFL tutorial here.

CCI Trading System – AFL Overview

Parameter Value
Preferred Time-frame
Daily
Indicators Used CCI (Commodity Channel Index)
Buy Condition
  • CCI(10) crosses zero line from bottom
  • CCI(10) > CCI(30)
Short Condition
  • CCI(10) crosses zero line from top
  • CCI(10) < CCI(30)
Sell Condition
  • Same as Short
  • Stop Loss Hit
  • Target met
Cover Condition
  • Same as Buy
  • Stop Loss Hit
  • Target met
Stop Loss 2%
Targets 5%
Position Size 150 (fixed)
Initial Equity 200000
Brokerage 100 per order
Margin 10%

CCI Trading System– AFL Code

//------------------------------------------------------
//
//  Formula Name:    CCI Trading system
//  Author/Uploader: Trading Tuitions
//  E-mail:          support@tradingtuitions.com
//  Website:         www.tradingtuitions.com
//------------------------------------------------------

_SECTION_BEGIN("CCI Trading System");

SetBarsRequired( sbrAll );
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C ));

//Initial Parameters
SetTradeDelays( 1,1,1, 1 );
SetOption( "InitialEquity", 200000);
SetOption("FuturesMode" ,True);
SetOption("MinShares",1);
SetOption("CommissionMode",2);
SetOption("CommissionAmount",100);
SetOption("AccountMargin",10);
SetOption("RefreshWhenCompleted",True);
SetPositionSize(150,spsShares);
SetOption( "AllowPositionShrinking", True );

Plot( Close, "Price",colorWhite, styleCandle );

CCISlow=Param("CCISlow",30,30,100,10);
CCIFast=Param("CCIFast",10,5,30,5);
 
Buy = Cross( CCI(CCIFast), 0 ) AND CCI(CCIFast) > CCI(CCISlow) ;
 
Short = Cross( 0,CCI(CCIFast)) AND CCI(CCIFast) < CCI(CCISlow);

Sell=Short;
Cover=Buy; 

BuyPrice=Open;
SellPrice=Open;
ShortPrice=Open;
CoverPrice=Open;

Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Short=ExRem(Short,Cover);
Cover=ExRem(Cover,Short);

printf("\nBuy : " + Buy );  
printf("\nSell : " + Sell );  
printf("\nShort : " + Short );  
printf("\nCover : " + Cover );  

StopLoss=Param("SL",2,1,10,1);
Target=Param("Target",5,5,40,5);
ApplyStop(Type=0,Mode=1,Amount=StopLoss);
ApplyStop(Type=1,Mode=1,Amount=Target);
 
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Cover, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);

_SECTION_END();


AFL Screenshot

CCI Trading System

CCI Trading System- Backtest Report

CCI Trading system is consistent and its moderate drawdown should be ok for mild aggressive traders. 20% CAGR over last 6 years looks good for long term capital growth.

Parameter Value
Nifty
Initial Capital 200000
Final Capital 772617.80
Scrip Name NSE Nifty
Backtest Period 01-Jan-2010 to 24-Apr-2017
Timeframe Daily
Net Profit % 286.31%
Annual Return % 20.32%
Number of Trades 99
Winning Trade % 42.42%
Average holding Period 7.88 periods
Max consecutive losses 6
Max system % drawdown -27.43%
Max Trade % drawdown -37.62%

Download the detailed backtest report here.

Equity Curve

The equity curve smoother than most of the trading system we have posted. Periods of mild drawdown are inevitable for any system.

CCI Trading System - Equity Curve

Profit Table

CCI Trading System - Profit Table

Additional Amibroker settings for backtesting

Goto Symbol–>Information, and specify the lot size and margin requirement. The below screenshot shows lot size of 75 and margin requirement of 10% for NSE Nifty:

Symbol Info_Nifty

Disclaimer:

All the AFL’s posted in this section are for learning purpose. Trading Tuitions does not necessarily own these AFL’s and we don’t have any intellectual property rights on them. We might copy useful AFL’s from public forums and post it in this section in a presentable format. The intent is not to copy anybody’s work but to share knowledge. If you find any misleading or non-reproducible content then please inform us at support@tradingtuitions.com

3 Comments

  1. I’ve AFL get from free trial… but not able to sue without subscription, is it possible to edit by your and make as useful ???

  2. hi admin, can you post some intraday scalping systems ?
    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *