# CCI strategy

2924 2
The Commodity Channel Index ( CCI ) is best used with markets that display cyclical or
seasonal characteristics, and is formulated to detect the beginning and ending of these
cycles by incorporating a moving average together with a divisor that reflects both possible
and actual trading ranges. The final index measures the deviation from normal, which indicates
major changes in market trend.

To put it simply, the Commodity Channel Index ( CCI ) value shows how the instrument is trading
relative to its mean (average) price. When the CCI value is high, it means that the prices are
high compared to the average price; when the CCI value is down, it means that the prices are low
compared to the average price. The CCI value usually does not fall outside the -300 to 300 range
and, in fact, is usually in the -100 to 100 range.
```////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 17/06/2014
// The Commodity Channel Index (CCI) is best used with markets that display cyclical or
// seasonal characteristics, and is formulated to detect the beginning and ending of these
// cycles by incorporating a moving average together with a divisor that reflects both possible
// and actual trading ranges. The final index measures the deviation from normal, which indicates
// major changes in market trend.
// To put it simply, the Commodity Channel Index (CCI) value shows how the instrument is trading
// relative to its mean (average) price. When the CCI value is high, it means that the prices are
// high compared to the average price; when the CCI value is down, it means that the prices are low
// compared to the average price. The CCI value usually does not fall outside the -300 to 300 range
// and, in fact, is usually in the -100 to 100 range.
////////////////////////////////////////////////////////////
study(title="CCI strategy", shorttitle="CCI strategy")
FastMA = input(10, minval=1)
SlowMA = input(20, minval=1)
hline(0, color=purple, linestyle=dashed)
xCCI = cci(close, 10)
xSMA = sma(xCCI,SlowMA)
xFMA = sma(xCCI,FastMA)
pos = iff(xSMA < xFMA , 1,
iff(xSMA > xFMA, -1, nz(pos[1], 0)))
barcolor(pos == -1 ? red: pos == 1 ? green : blue)
plot(xSMA, color=red, title="CCI MA Slow")
plot(xFMA, color=blue, title="CCI MA FAST")
```
DONATE/TIP

BTC: 1Lo1GoTNsPbrjGAgPgF4MYZPhBFdoVHaTm
Hi Harry,

Thank you for this indicator. It looks great. I have been backtesting it (the way I thought it worked), but although I found it worked very well sometimes, others it seemed completely off... So I think I might have got a wrong idea of the usage: would you mind doing a small explanation on how to use the indicator? I find it confusing that my candles change to the opposite color when this indicator is active.

Thanks!!
DiegoKatzman
Hi Diego,
Candles is that change a color because this version of the indicator work as strategy. It painting candles in red when they think that now short position and green that now long position. If you would like that candles do not change a color, you should to use a simple CCI indicator. I do not use this indicator, I programmed it for education.
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter