top of page

Thinkscript Library

Public·1 member

Choppiness Index — Volatility Drop


The Choppiness Index tells you *when* the market is trending versus chopping sideways — not which direction. Use it as a regime filter to switch between trend-following and mean-reversion tactics.


## What it does

- Measures how directional price has been over a lookback window using the ratio of summed True Range to the total high-low range.

- Scales the result to a clean 0–100 oscillator via a log normalization.

- High readings (≥ 61.8) flag choppy, range-bound conditions; low readings (≤ 38.2) flag strong trends.

- Color-codes the line (yellow = chop, cyan = trend, gray = neutral) and shows a live regime label.

- Fires alerts the bar the market crosses into a trend or chop regime.


## Recommended settings

- Length: 14

- Chop threshold: 61.8

- Trend threshold: 38.2

- Mid reference: 50


## Ideal timeframe

Works on any timeframe; most reliable as a regime filter on 15m–4h and daily charts.


## How to use

Treat the Choppiness Index as a gate, not a trigger. When the line is low (≤ 38.2) and falling, price is trending — favor breakout and pullback entries and let trend tools lead. When the line is high (≥ 61.8), the market is coiling sideways — fade the edges of the range and distrust breakouts until the index rolls back down. The Fibonacci-derived 61.8 / 38.2 bands are the classic thresholds; the cyan/yellow coloring and background tint make the active regime obvious at a glance.


## thinkScript code

```

# ─────────────────────────────────────────────

# │ MarketFragments.com | DNA & Market │

# │ info@marketfragments.com │

# │ www.marketfragments.com │

# ─────────────────────────────────────────────

# Time →

# │

# █ █ █│ █

# █ █ █ │ █ █

# █ █ █ │ █ █ █ ╭─╮

# █ █ █ │ █ █ █ █ ╭─╯ ╰─╮

# █ █ █ │ █ █ █ █ █ █ ╭─╯ ╰─╮

# █ █ █ │ █ █ █ █ █ █ █ █ ╭─╯ ╰─╮

# █ █ █ │ █ █ █ █ █ █ █ █ █ █╭─╯ ╰─╮

# █ █ █ │ █ █ █ █ █ █ █ █ ╰─╮ ╭─╯

# █ █ █ │ █ █ █ █ █ █ ╰─╮ ╭─╯

# █ █ █ │ █ █ █ █ ╰─╮ ╭─╯

# █ █ █ │ █ █ ╰─╮ ╭─╯

# █ █ █ │ █ ╰─────╯

# ──────┴──────────────────────────────────────────────────────────────

# T1 T2 T3 T4 T5 T6

#

# Choppiness Index — volatility / trend-vs-range regime oscillator

# Measures whether price is trending or chopping over a lookback window.

# Free for non-commercial use. Attribution to MarketFragments.com appreciated.


declare lower;


input length = 14;

input chopThreshold = 61.8;

input trendThreshold = 38.2;


def tr = TrueRange(high, close, low);

def trSum = Sum(tr, length);

def hh = Highest(high, length);

def ll = Lowest(low, length);

def rng = hh - ll;


plot CI = if rng > 0 then 100 * Log(trSum / rng) / Log(length) else Double.NaN;

CI.SetLineWeight(2);

CI.AssignValueColor(

if CI >= chopThreshold then Color.YELLOW

else if CI <= trendThreshold then Color.CYAN

else Color.GRAY);


plot ChopBand = chopThreshold;

plot TrendBand = trendThreshold;

plot Mid = 50;

ChopBand.SetDefaultColor(Color.DARK_ORANGE);

TrendBand.SetDefaultColor(Color.GREEN);

Mid.SetDefaultColor(Color.GRAY);

Mid.SetStyle(Curve.SHORT_DASH);


AddCloud(CI, chopThreshold, Color.YELLOW, Color.CURRENT);

AddCloud(trendThreshold, CI, Color.CYAN, Color.CURRENT);


AddLabel(yes,

"CHOP " + Round(CI, 1) +

(if CI >= chopThreshold then " | CHOPPY"

else if CI <= trendThreshold then " | TRENDING"

else " | NEUTRAL"),

if CI >= chopThreshold then Color.YELLOW

else if CI <= trendThreshold then Color.CYAN

else Color.GRAY);


Alert(CI crosses below trendThreshold, "Choppiness: entering TREND regime", Alert.BAR, Sound.Ding);

Alert(CI crosses above chopThreshold, "Choppiness: entering CHOP regime", Alert.BAR, Sound.Ding);

```


Drop your tweaks, screenshots, and questions below — that's how the library gets better.


2 Views
Brain with financial data analysis.

Inquiries at :

Important Risk Notice: Trading involves substantial risk of loss. This is educational content only—not advice. Full details here  ------------>  

Proceed only if you're prepared.

tel#: (843) 321-8514

bottom of page