Choppiness Index Indicator for ThinkorSwim

tomsk

Well-known member
VIP
For those interested, here is a Choppiness Indicator that Mobius posted several years ago. This is helpful for those who'd like another measure of defining trend, chop, etc
aPXXZsk.png


The Choppiness Index was developed by Australian commodity trader E.W. Dreiss and may be used to determine if the market is consolidating or trending.

The Choppiness Index is a directionless indicator.
Values above the upper guide (61.8) indicate that the market is moving sideways in a ranging or choppy manner.
Values below the lower guide (38.2) indicate the market is trending.

The CI measures the relationship between the Sum of daily trading ranges during a given period of time against the total range for that period.
Low readings in the CI correspond closely with the end of strong impulsive movements either up OR down, while High readings occur after significant consolidations in the price. Extended periods of trendless price movement are reflected in extended periods of above-average readings of the CI.

Bill Dreiss says,
High CI readings can be used to indicate that a consolidation is about to end, and a position should be entered or a breakout anticipated. Since the CI reading has nothing to do with market direction, it does NOT indicate in which direction to expect the breakout, but that the breakout will probably be followed by a significant move. In this respect, the CI is similar in usage to Bollinger Band width (%B).
Commodity Traders Consumer Report, July/August, 1992, Bill Dreiss “The Fractal Wave Algorithm, Charts And Systems”

CI is similar to ADX where values below the 38.2 line coincides with ADX values above 20 which show a trending market. The author Driess preferred his solution over ADX.

Code:
# Choppiness Indicator
# Mobius
# V001.03.2012

#Hint: The Market is considered TRENDING when the index is below 38.2 \n The Market is considered CHOPPY when the index is above 61.8. \n A move above the 38.2 Level indicates a possible end to a trend and a move below 61.8 indicates a possible breakout from a period of consolidation.


declare lower;
input Length   = 14;
input Signal   =  3;
input Choppy   = 62;
input MidLine  = 50;
input Trending = 38;
input CIx = {default CIB, CIA};
   def CIA = 100 * log( Sum( TrueRange(high, close, low), Length))
             / ( Highest(close[1], Length) - Lowest(close[1], Length))
             / log(Length);
   def CIB = ((log(Sum(TrueRange(high, close, low), Length) /
             (Highest(if high >= close[1] then high else
             close[1], Length) -
             Lowest( if low <= close[1] then low else close[1], Length)))
             / log(10)) / (log(Length)/log(10))) * 100;
  plot CI = if CIx == CIx.CIB then CIB else CIA;
       CI.SetDefaultColor( Color.White);
  plot CIavg = average(CI, Signal);;
       CIavg.setdefaultColor(Color.Green);
  plot Chop = Choppy;
       Chop.SetDefaultColor(Color.red);
  plot Mid = MidLine;
       Mid.SetDefaultColor(Color.gray);
  plot Trend = Trending;
       Trend.SetDefaultColor(Color.green);
AddLabel(yes, if CI > MidLine then "CHOPPY " else "TRENDING ", if CI < Trend then Color.Green else if CI > Trend and CI < MidLine then Color.Light_Green else if CI > MidLine and CI < Chop then Color.Yellow else Color.Red);
Addcloud(Mid, Chop, Color.Green, Color.Yellow);
Addcloud(Trend, Mid, Color.Yellow, Color.Light_Green);
# END CODE #

Updated version from 2015

Code:
# Choppiness Index
# UpTheCreek
# 09.21.2015
# V 1.0

# Choppiness Index was developed by Australian commodity trader E.W. Dreiss
# and may be used to determine if the market is consolidating or trending.
# The Choppiness Index is a directionless indicator. Values above the upper
# guide (61.8) indicate that the market is moving sideways in a ranging or
# choppy manner. Values below the lower guide (38.2) indicate the market is
# trending.
#
# The CI measures the relationship between the Sum of daily trading ranges
# during a given period of time against the total range for that period.
# Low readings in the CI correspond closely with the end of strong impulsive
# movements either up OR down, while High readings occur after significant
# consolidations in the price. Extended periods of trendless price movement
# are reflected in extended periods of above-average readings of the CI.
#
# Bill Dreiss says "high CI readings can be used to indicate that a
# consolidation is about to end and a position should be entered or a
# breakout anticipated. Since the CI reading has nothing to do with market
# direction, it does NOT indicate in which direction to expect the breakout,
# but that the breakout will probably be followed by a significant move.)
# In this respect, the CI is similar in usage to Bollinger Band width (%B).
#
# Commodity Traders Consumer Report, July/August, 1992, Bill Dreiss “The
# Fractal Wave Algorithm, Charts And Systems”
#
# CI is similar to ADX where values below the 38.2 line coincides with ADX
# values above 20 which show a trending market. The author Driess preferred
# his solution over ADX.

declare lower;
input length = 14;
input UseLabels = yes;

def Hmax=highest(high, length);
def Lmin=lowest(low, length);

plot choppiness = 100* log(sum(truerange(high, close, low),length)/(Hmax-Lmin))/log(length);
choppiness.SetDefaultColor(Color.BLUE);
choppiness.SetLineWeight(1);

plot choppy=61.8;
choppy.SetDefaultColor(GetColor(2));
choppy.SetLineWeight(1);
choppy.SetStyle(Curve.POINTS);

plot trending=38.2;
trending.SetDefaultColor(GetColor(2));
trending.SetLineWeight(1);
trending.SetStyle(Curve.POINTS);

AddLabel(UseLabels && choppiness > choppy, "Consolidating, watch for break", Color.RED);
AddLabel(UseLabels && choppiness < trending, "Trending, watch for chop", Color.DARK_GREEN);

# End Study
 
Last edited by a moderator:
Here's a simple indicator, it's not going to tell you if the market is going up or down, instead, it will tell you when the market is moving sideways. The indicator was made to solve my problem. I hate executing trades in choppy markets.

I think this indicator is going to be a great assistant when it comes to dealing with choppy markets. It could potentially save your account.

mHJotsS.png


Usage:

Sideways indicator comes in the form of an oscillator. By combining the range between DI+ and DI- lines from the DMI indicator.

When two lines are close to each other it means we have a sideways market. I would avoid trading when this happens. Also, the indicator will highlight the candles when it's experiencing choppiness.

Recommended timeframe: 5m and 15m for intraday traders.

Code:
# Sideways Indicator
# Original Code developed by WalkingBallista
# Concept and Idea by BenTen at useThinkScript.com
# Identify choppy market. Can also be used to find consolidation/breakout patterns.
# Version 1.0 (read changelog in the forum)

declare lower;
input length = 14;
input averageType = AverageType.WILDERS;
input price = close;

def hiDiff = high - high[1];
def loDiff = low[1] - low;

def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;

def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
def "DI+" = 100 * MovingAverage(averageType, plusDM, length) / ATR;
def "DI-" = 100 * MovingAverage(averageType, minusDM, length) / ATR;

plot range = AbsValue(AbsValue("DI+")-AbsValue("DI-"));

# Define Consolidation Range
# Change the number 5 to 10 if you want more sideways filter
AssignPriceColor(if range < 5 then Color.Yellow else Color.Current);

Shareable Link https://tos.mx/KkZ7M1
 

Attachments

  • mHJotsS.png
    mHJotsS.png
    114.9 KB · Views: 553
Last edited:
When two lines are close to each other it means we have a sideways market.

What am I missing? There's only one line in your posted chart and on mine.
 
@Greenbacks Yes, the good thing is that it should work without any additional modification. Just make sure to set the correct timeframe you want to use for the watchlist column.
 
Thanks man. Can you edit the code so that I dont see the lower study, but only a text such as "Market Sideways " or "Market Choppy" displays on the top left of the chart, and the candle color changes as you have already done?
 
Last edited:
@thealphabreed Here is the modified code, removed the lower study and only highlight choppy candles on your chart:

Code:
# Sideways Indicator
# Original Code developed by WalkingBallista
# Concept and Idea by BenTen at useThinkScript.com
# Identify choppy market. Can also be used to find consolidation/breakout patterns.
# Version 1.0 (read changelog in the forum)

input length = 14;
input averageType = AverageType.WILDERS;
input price = close;

def hiDiff = high - high[1];
def loDiff = low[1] - low;

def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM =  if loDiff > hiDiff and loDiff > 0 then loDiff else 0;

def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
def "DI+" = 100 * MovingAverage(averageType, plusDM, length) / ATR;
def "DI-" = 100 * MovingAverage(averageType, minusDM, length) / ATR;

def range = AbsValue(AbsValue("DI+")-AbsValue("DI-"));

# Define Consolidation Range
# Change the number 5 to 10 if you want more sideways filter
AssignPriceColor(if range < 5 then Color.Yellow else Color.Current);
 
Thanks @BenTen You rock!
On a sidenote, which timeframe, in your experience, is best for trading (daytrading).
I have been struggling to choose between 1 min and 5min
1min gives so many false moves
and with 5min, the price breaks out, but then reverses 10-20c (sometimes) before making a move up again.
Any suggestions/advise would help!
 

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
402 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