CCI Upper Bands for ThinkorSwim

chewie76

Well-known member
VIP
VIP Enthusiast
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.

1759891099515.png


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
 
How to Read It
  • When price touches or breaks above the +150 (red) band → strong upside momentum or potential exhaustion.
  • When price touches or breaks below the –150 (green) band → strong downside momentum or potential exhaustion.
  • The yellow midline (0 CCI) is your mean reversion anchor.
  • The clouds between ±100/±150 bands show momentum zones:
    • Red cloud above = overbought/momentum expansion zone.
    • Green cloud below = oversold/momentum expansion zone.

Trading Ideas and Tactics
1. Mean Reversion Trades
This is the classic way to use CCI-type bands.
  • Setup:
    • Price extends into red (above +100 or +150) or green (below –100 or –150) cloud.
    • Wait for a rejection candle or cross back inside the cloud.
  • Trade:
    • Short after a rejection from the red zone.
    • Long after a rejection from the green zone.
  • Exit: at the yellow midline (mean level).
    This approach assumes the move is overextended and due to revert.
2. Momentum Continuation Trades
If you prefer trend trading:
  • Setup:
    • Price closes above +150 with rising volume → breakout continuation.
    • Price closes below –150 → breakdown continuation.
  • Trade:
    • Enter with the direction of the move (buy strength, short weakness).
    • Place stop-loss just inside the ±100 band.
  • Exit: when price crosses back into the neutral (gray) zone or hits the opposite ±100 band.

This approach assumes the move is expanding volatility, not reverting.

3. Confluence Trading (Best Practice)
Combine this CCI Bands indicator with:
  • Trend filter (e.g., 21 EMA or VWAP) — only take longs above it, shorts below it.
  • Volume confirmation — look for expansion as price exits ±100 zones.
  • Momentum tools — like RSI or MACD confirming direction.

That helps you distinguish trend continuation from false reversals.

Quick Reference Table
Signal TypeZoneBiasEntry TriggerExit Target
Overbought reversalAbove +100/+150BearishClose back below bandMidline
Oversold reversalBelow –100/–150BullishClose back above bandMidline
Bullish breakoutAbove +150BullishStrong close + volumePullback or –100 band
Bearish breakoutBelow –150BearishStrong close + volumePullback or +100 band
 
Last edited by a moderator:
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.

View attachment 25920

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
Here is a scanner for bullish stocks meeting the CCI_Bands extreme conditions
https://tos.mx/!RL4gOif9
1759900482670.png
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
397 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top