Commodity channel index
How far the typical price sits from its recent average, scaled by recent spread; beyond ±100 reads as stretched.
CCI takes each bar's typical price, the average of high, low and close, and measures how far it sits from the average of recent typical prices. It divides that gap by the mean absolute deviation of those prices and a fixed 0.015, so the reading scales with recent price spread rather than with the price level. The code looks off: once the window fills, the average covers the previous window bars plus the current bar, 21 prices at the default, so readings reach ±700 where a standard 20-price CCI stops near ±667.
How to read it
- The line sits in its own pane below the price. Zero means the typical price sits at its recent average.
- Above +100 the price is stretched above its average; below -100, stretched below. Beyond ±175 happens on about one bar in ten on SPY one-minute bars at the default window.
- A turn back toward zero after an extreme shows the stretch easing. A line that stays beyond ±100 for many bars shows a trend, not a reversal.
What it outputs
- CCI
- The typical price's distance from its recent average, scaled by recent spread. Zero is average; positive is above, negative below.
Settings
- Window
- Bars the average and spread cover. Raising it averages over more bars, so the line moves slowly and reaches the extremes less often; lowering it swings faster and hits the extremes on short noise.
Pitfalls
- The ±700 extremes come from a 21-price average, not the 20 the window names, so the top and bottom of the pane run wider than the parameter implies.
- Readings beyond ±100 are ordinary on one-minute bars; about one bar in ten passed ±175 on the sample month, so ±100 alone is not a signal.
- The first 19 bars at the default window have no value, so the line starts after them.