This is the CCI on the upper chart using 100 and 150 levels as bands. It also indicates squeezes in volatility. These squeezes are highlighted in cyan color bars, shaded areas, and cyan dots. Below is the SPY on a 1 hour chart. Notice the squeeze zones and the breakouts. These are good areas to place a straddle option trade as you know a move will take place, but not sure what direction. The sensitivity of the squeezes can be adjusted in the setting. Default is 0.618.
Color bars can be turned off in the settings. You can also turn off the bands in the settings.
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 = no;
input length = 14;
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.RED);
CCId.SetDefaultColor(Color.GREEN);
CCIu2.SetDefaultColor(Color.RED);
CCId2.SetDefaultColor(Color.GREEN);
CCIm.SetDefaultColor(Color.YELLOW);
ccim.setlineWeight(2);
#-----------------------------------------------
# Optional 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);
#-----------------------------------------------
# Band Squeeze Detection
#-----------------------------------------------
input squeezeThreshold = 0.618; # 0.5 = very sensitive, 1.0 = only tightest periods
def bandWidth = bandHigh2 - bandLow2; # Total distance between outer bands
def avgWidth = Average(bandWidth, length); # Smooth average width
def squeeze = bandWidth < avgWidth * squeezeThreshold; # "Tight" if less than 75% of normal width
# Optional visual marker
plot SqueezeSignal = if squeeze then bandMid else Double.NaN;
SqueezeSignal.SetPaintingStrategy(PaintingStrategy.POINTS);
SqueezeSignal.SetDefaultColor(Color.CYAN);
SqueezeSignal.SetLineWeight(3);
# Optional background color highlight
AddCloud(
if squeeze then bandHigh else Double.NaN,
if squeeze then bandLow else Double.NaN,
Color.GRAY,
Color.GRAY
);
AssignPriceColor(
if squeeze then Color.CYAN
else 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
Last edited: