This is the CCI on the upper chart using 100 and 150 levels as bands. I like the 8 period length, but adjust as you see fit. Below is the SPX on a 5 minute chart. Color bars can be turned off in the settings. You can also turn off the bands in the settings.
Code:
#-----------------------------------------------
# CCI Upper Chart Bands Indicator
# Shows price bands corresponding to CCI = +150/+100/0/-100/-150
# Assembled by Chewie 10/2025
#-----------------------------------------------
input colorbar = yes;
input length = 8;
input first = yes;
input second = yes;
input price = close;
# --- CCI Levels ---
input cciHigh = 100;
input cciLow = -100;
input cciHigh2 = 150;
input cciLow2 = -150;
input cciMid = 0;
#-----------------------------------------------
# Core CCI and Derived Bands
#-----------------------------------------------
def mean = Average(price, length);
def dev = Average(AbsValue(price - mean), length);
# Convert CCI levels into price levels
def bandHigh = mean + cciHigh * 0.015 * dev;
def bandLow = mean + cciLow * 0.015 * dev;
def bandHigh2 = mean + cciHigh2 * 0.015 * dev;
def bandLow2 = mean + cciLow2 * 0.015 * dev;
def bandMid = mean + cciMid * 0.015 * dev;
#-----------------------------------------------
# Plot CCI Price Bands
#-----------------------------------------------
plot CCIu = if first then bandHigh else Double.NaN;
plot CCId = if first then bandLow else Double.NaN;
plot CCIu2 = if second then bandHigh2 else Double.NaN;
plot CCId2 = if second then bandLow2 else Double.NaN;
plot CCIm = bandMid;
CCIu.SetDefaultColor(Color.DARK_RED);
CCId.SetDefaultColor(Color.DARK_GREEN);
CCIu2.SetDefaultColor(Color.RED);
CCId2.SetDefaultColor(Color.GREEN);
CCIm.SetDefaultColor(Color.YELLOW);
#-----------------------------------------------
# Clouds between Bands
#-----------------------------------------------
AddCloud(CCIu2, CCIu, Color.DARK_RED, Color.DARK_RED);
AddCloud(CCId, CCId2, Color.DARK_GREEN, Color.DARK_GREEN);
#-----------------------------------------------
# Optional Bar Coloring by CCI Level
#-----------------------------------------------
def CCI = if dev != 0 then (price - mean) / (0.015 * dev) else 0;
AssignPriceColor(
if !colorbar then Color.CURRENT
else if CCI >= cciHigh2 then Color.RED
else if CCI >= cciHigh then Color.DARK_RED
else if CCI <= cciLow2 then Color.GREEN
else if CCI <= cciLow then Color.DARK_GREEN
else Color.gray);
# END CODE