CCI Indicator (Amibroker And Tradestation Code)

The original article can be found here.

CCI trading strategy

Plain English:

  • We use an N-day lookback period (2 to 10 days).
  • We go long when the CCI crosses below the CCI buy threshold (-50 to -10).
  • We sell when the CCI crosses above the sell threshold (10 to 50).

Amibroker code:

oddis=Optimize(“Lookback period”,3,2,10,1) ;
thresholdBuy=Optimize(“Threshold Buy”,-50,-50,-10,10) ;
thresholdSell=Optimize(“Threshold Sell”,50,10,50,10) ;

Buy = Cross(thresholdBuy, CCI(oddis)) ;
BuyPrice=Close;
Sell = Cross(CCI(oddis),thresholdSell) ;
SellPrice=Close;

Tradestation code:

{
Strategy 118 - CCI indicator
We use an N-day lookback period (2 to 10 days).
We go long when the CCI crosses below the CCI buy threshold (-50 to -10).
We sell when the CCI crosses above the sell threshold (10 to 50).
}

Inputs: 
	Lookback(3),
	BuyTreshold(-50),
	SellTreshold(50);

if CCI(Lookback) cross under BuyTreshold Then
	buy this bar on close;

if CCI(Lookback) cross over SellTreshold then 
	sell this bar on close;