Appearance
Commodity Channel Index
Deviation from the mean in units of mean deviation.
Kind indicator · Drawn in its own pane
Try it
On the chart, press / and choose Commodity Channel Index under Oscillators. To change it, copy the source below into the AlphaScript editor.
Inputs
| Input | Type | Default |
|---|---|---|
| Length | int | 20 |
| Source | source | "hlc3" |
| Color | color | "#2962FF" |
Source
From packages/alphascript/indicators/cci.as.js.
js
indicator({ name: "Commodity Channel Index", shortTitle: "CCI", overlay: false, precision: 2 });
const length = input.int("Length", 20, { min: 1 });
const src = input.source("Source", "hlc3");
plot(ta.cci(src, length), { title: "CCI", color: input.color("Color", "#2962FF", { group: "Style" }) });
hline(100, { title: "Upper band", color: "#787B86", style: "dashed" });
hline(0, { title: "Middle band", color: "rgba(120,123,134,0.5)", style: "dotted" });
hline(-100, { title: "Lower band", color: "#787B86", style: "dashed" });
fill(100, -100, { title: "Background", color: "rgba(33,150,243,0.1)" });