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

SlotAvailableRole
Entry PointNo—
Entry RuleYesFilters entries by the CCI direction or its level position.
Exit PointNo—
Exit RuleYesTriggers 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:

RuleLong signal is 1 whenShort signal is 1 when
CCI risesCCI rose on the previous barCCI fell on the previous bar
CCI fallsCCI fell on the previous barCCI rose on the previous bar
CCI is higher than the Level lineCCI is above LevelCCI is below −Level
CCI is lower than the Level lineCCI is below LevelCCI is above −Level
CCI crosses the Level line upwardCCI crossed above Level from belowCCI crossed below −Level from above
CCI crosses the Level line downwardCCI crossed below Level from aboveCCI crossed above −Level from below
CCI changes its direction upwardCCI formed a valley (down then up)CCI formed a peak (up then down)
CCI changes its direction downwardCCI 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

ParameterTypeDefaultRangePurpose
Apply toselectTypicalOpen, High, Low, Close, Median, Typical, WeightedPrice series the CCI is calculated from
Periodnumber142 to 1000Bars of the mean and the deviation
Levelnumber100−1000 to 1000Long 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.