Choppiness Index
Whether the market trends or chops sideways, on a 0 to 100 scale with the 38.2 and 61.8 guides.
- CHOP
- Built into Spectral
- Updates every tick
- choppiness
- chop
- sideways
- range or trend
- trend filter
- fibonacci levels
MIT-0: free to use, change and share, no attribution needed. What you build from it is yours.
Already in Spectral: add it from the Indicators toolbox. The file here is the same indicator written as a custom indicator, to change or learn from. Installed, it appears next to the built-in one, marked Custom.

Overview
The Choppiness Index by E. W. Dreiss compares the path price travelled with the ground it covered. It adds up the true range of every bar in the window and divides that sum by the window's high-low range: a market that moves in one direction covers its range in a short path, a market that swings back and forth travels a long path inside a small range.
The result is scaled with a logarithm to 0-100: 100 times log10(sum of true ranges / (highest high - lowest low)) / log10(Length).
How to read it
High values (above 61.8) mark choppy, sideways conditions; low values (below 38.2) mark a directional trend. The index says nothing about the direction of that trend.
Traders use it as a filter: trend-following entries when it falls below the trending level, range tactics or patience while it stays high. A long stretch of high values often precedes a breakout, and a very low value after a strong move often comes before a pause.
Settings and limitations
Length 14 is the common default. The guides use the Fibonacci levels 61.8 and 38.2; change them to suit the market. Values appear after Length bars; a window without any range shows no value.
Notes
Matches TradingView's Choppiness Index: the true range includes gaps from the previous close and the high-low range covers the same Length bars.
Settings
Each setting appears in the indicator's settings panel in Spectral, next to a color setting for every output.
| Setting | Type | Default | Range or options | What it does |
|---|---|---|---|---|
| Length | Whole number | 14 | 2 – 500 | Number of bars compared: the sum of their true ranges against the range from their highest high to their lowest low. |
| Choppy level | Number | 61.8 | 0 – 100, step 0.1 | Guide above which the market counts as choppy (sideways). |
| Trending level | Number | 38.2 | 0 – 100, step 0.1 | Guide below which the market counts as trending. |
What it draws
Lines
- CHOPsolid · 1.5 px · primary
#58A6FF
Levels
- Choppydotted · 1 px · value on the axis
#788493 - Trendingdotted · 1 px · value on the axis
#788493
Zones
- Neutral bandfilled at 6% opacity
#58A6FF
Source
Save it as choppiness-index.js and add it with Indicators → Custom indicators → Add file…. The format is explained in the custom indicators guide.
// Copyright (c) 2026 Spectral
// SPDX-License-Identifier: MIT-0
// Free to use, copy, modify and share: https://spectral.trade/docs/custom-indicators/LICENSE.txt
/** @type {import('./spectral-indicator').IndicatorV2} */
export default {
schemaVersion: 2,
id: 'choppiness-index',
name: 'Choppiness Index',
shortName: 'CHOP',
version: '1.0.0',
author: 'Spectral',
description: 'Whether the market trends or chops sideways, on a 0 to 100 scale with the 38.2 and 61.8 guides.',
pane: 'oscillator',
live: { lookback: 'length' },
inputs: {
length: { type: 'integer', label: 'Length', default: 14, min: 2, max: 500, description: 'Number of bars compared: the sum of their true ranges against the range from their highest high to their lowest low.' },
upperLevel: { type: 'number', label: 'Choppy level', default: 61.8, min: 0, max: 100, step: 0.1, description: 'Guide above which the market counts as choppy (sideways).' },
lowerLevel: { type: 'number', label: 'Trending level', default: 38.2, min: 0, max: 100, step: 0.1, description: 'Guide below which the market counts as trending.' },
},
plots: {
chop: { label: 'CHOP', color: '#58A6FF', lineWidth: 1.5, primary: true },
},
levels: {
upper: { label: 'Choppy', color: '#788493', lineStyle: 'dotted', showValue: true },
lower: { label: 'Trending', color: '#788493', lineStyle: 'dotted', showValue: true },
},
zones: {
band: { label: 'Neutral band', color: '#58A6FF', opacity: 0.06 },
},
docs: {
overview: 'The Choppiness Index by E. W. Dreiss compares the path price travelled with the ground it covered. It adds up the true range of every bar in the window and divides that sum by the window\'s high-low range: a market that moves in one direction covers its range in a short path, a market that swings back and forth travels a long path inside a small range.\n\nThe result is scaled with a logarithm to 0-100: 100 times log10(sum of true ranges / (highest high - lowest low)) / log10(Length).',
howToRead: 'High values (above 61.8) mark choppy, sideways conditions; low values (below 38.2) mark a directional trend. The index says nothing about the direction of that trend.\n\nTraders use it as a filter: trend-following entries when it falls below the trending level, range tactics or patience while it stays high. A long stretch of high values often precedes a breakout, and a very low value after a strong move often comes before a pause.',
settings: 'Length 14 is the common default. The guides use the Fibonacci levels 61.8 and 38.2; change them to suit the market. Values appear after Length bars; a window without any range shows no value.',
notes: 'Matches TradingView\'s Choppiness Index: the true range includes gaps from the previous close and the high-low range covers the same Length bars.',
},
calculate(ctx) {
const { bars, inputs, ta } = ctx;
const length = inputs.length;
const rangeSum = ta.sum(ta.trueRange(bars), length);
const highest = ta.highest(ta.source(bars, 'high'), length);
const lowest = ta.lowest(ta.source(bars, 'low'), length);
const scale = Math.log10(length);
const chop = rangeSum.map((sum, index) => {
const span = highest[index] === null || lowest[index] === null ? 0 : highest[index] - lowest[index];
return sum === null || !(span > 0) || !(sum > 0) ? null : (100 * Math.log10(sum / span)) / scale;
});
const upper = chop.map((value) => (value === null ? null : inputs.upperLevel));
const lower = chop.map((value) => (value === null ? null : inputs.lowerLevel));
return {
plots: { chop },
levels: { upper: inputs.upperLevel, lower: inputs.lowerLevel },
zones: { band: { upper, lower } },
};
},
};Adapt it with an LLM
Paste this into your assistant and replace the second-to-last line with the change you want.
Start from this Spectral custom indicator: https://spectral.trade/indicators/choppiness-index.js Format reference: https://spectral.trade/docs/custom-indicators.llm.md Keep the file format and every rule of the reference; give the result a new id, name, shortName and version, and update docs and input descriptions to match. Keep its live updates exact and fast (section "Fast live updates" of the reference): carry values from bar to bar only through ctx.ta, and raise live.lookback if the change reads further back; Spectral rejects a file whose live updates differ from a full recalculation or are too slow. Change I want: <describe the change> Answer with the complete file in one code block, ready to save as <id>.js.


