Commodity Channel Index
The Commodity Channel Index measures how far the price deviates from its statistical mean to identify overbought and oversold levels.
Role in the strategy
| Slot | Available | Role |
|---|---|---|
| Entry Point | No | — |
| Entry Rule | Yes | Filters entries by the CCI direction or its level position. |
| Exit Point | No | — |
| Exit Rule | Yes | Triggers exits by the CCI direction or its level position. |
The CCI produces conditions, not order prices. As an entry rule it is ANDed with the entry point and the other entry rules; as an exit rule it is ORed with the other exit rules. See Indicators for the slot semantics.
Logic rules
The indicator offers the standard oscillator rule set, evaluated on the CCI value:
| Rule | Long signal is 1 when | Short signal is 1 when |
|---|---|---|
| CCI rises | CCI rose on the previous bar | CCI fell on the previous bar |
| CCI falls | CCI fell on the previous bar | CCI rose on the previous bar |
| CCI is higher than the Level line | CCI is above Level | CCI is below −Level |
| CCI is lower than the Level line | CCI is below Level | CCI is above −Level |
| CCI crosses the Level line upward | CCI crossed above Level from below | CCI crossed below −Level from above |
| CCI crosses the Level line downward | CCI crossed below Level from above | CCI crossed above −Level from below |
| CCI changes its direction upward | CCI formed a valley (down then up) | CCI formed a peak (up then down) |
| CCI changes its direction downward | CCI formed a peak (up then down) | CCI formed a valley (down then up) |
The Level parameter sets the long threshold; the short threshold is always −Level.
Parameters
| Parameter | Type | Default | Range | Purpose |
|---|---|---|---|---|
| Apply to | select | Typical | Open, High, Low, Close, Median, Typical, Weighted | Price series the CCI is calculated from |
| Period | number | 14 | 2 to 1000 | Bars of the mean and the deviation |
| Level | number | 100 | −1000 to 1000 | Long threshold; the short threshold is −Level |
Calculation
tech.CCI in engine/indicator-engine/tech.ts computes:
- Typical price (or the selected price series).
- CCI =
(Price − SMA of Price) / (0.015 × Mean Deviation)over the Period.
The CCI line is drawn in a separate chart pane. The typical range is −100 to +100; values beyond that mark overbought and oversold conditions.
Backtesting
- The rule is evaluated on the previous (closed) bar with the standard dead zone (
SIGMA = 0.000001). - The indicator contributes only long/short signal arrays — it never changes the entry or exit order price.
- An entry happens only when the entry point allows the direction and every entry rule passes; an exit happens when the exit point is reached and any exit rule passes.