1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
44 lines of Pine Script v5 from inverse-choppines-index.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.
inverse-choppines-index.pine
//@version=5
indicator(title="Inverse Choppiness Index", shorttitle="TREND", format=format.price, precision=2, overlay = true)
length = input.int(14, minval=1)
ci = 100 * math.log10(math.sum(ta.atr(1), length) / (ta.highest(length) - ta.lowest(length))) / math.log10(length)
inverse_ci = (ci * -1) + 50
offset = input.int(0, "Offset", minval = -500, maxval = 500)
var color_veryhigh = input.color(color.new(color.black, 30), "very high")
var color_high = input.color(color.new(color.gray, 30), "high")
var color_low = input.color(color.new(color.blue, 30), "low")
var color_verylow = input.color(color.new(color.green, 30), "very low")
color_ci = ci > 61.8 ? color_veryhigh: (ci > 50 ? color_high : (ci > 38.2 ? color_low : color_verylow))
// plot(inverse_ci, "CHOP", color=color_ci, offset = offset, style = plot.style_columns)
// bgcolor(inverse_ci < 0 ? color.new(color.gray, 90) : color.white)
// Define the coordinates for the rectangle
var int x1 = na
var float y1 = na
var int x2 = na
var float y2 = na
// Coordinates for the rectangle (these could be based on your logic)
x1 := bar_index[length] // starting x-coordinate
y1 := ta.highest(length) // starting y-coordinate
x2 := bar_index // ending x-coordinate
y2 := ta.lowest(length) // ending y-coordinate
// Create a filled rectangle
var box rect = na
string my_session = input.session("0830-1500", title='NYSession')
timeinrange(res, sess) => not na(time(res, sess)) ? true : false
in_session = timeinrange(timeframe.period, my_session)
// Create new filled rectangle
// if inverse_ci < 0
if ci > 50 and in_session
// if (na(rect) == false)
// box.delete(rect)
rect := box.new(left=x1, top=y1, right=x2, bottom=y2, border_width=0, bgcolor=color.new(color.gray, 95))
Overview
When the Choppiness Index indicates high choppiness above a threshold of 50 during a defined trading session, the script plots a transparent rectangle over the price chart spanning the highest high and lowest low of the lookback period. Users can adjust the calculation length, session time filter, and threshold color preferences.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
length
int
14
length
Offset
int
0
offset
very high
color
color.new(color.black, 30)
color_veryhigh
high
color
color.new(color.gray, 30)
color_high
low
color
color.new(color.blue, 30)
color_low
very low
color
color.new(color.green, 30)
color_verylow
NYSession
session
0830-1500
my_session
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This indicator classifies the market into gamma regime types (negative gamma trend, positive gamma mean-reversion, or transition) by calculating a composite score based on daily ATR ratios, session VWAP crossover frequencies, and opening range displacement. It
42H Map calculates custom time cycle structures and session ranges directly on the price chart. It partitions market action into forty-two-hour cycles, ten-and-a-half-hour micro-sessions, half-week periods, and quarter-month segments to track highs, lows, and
This indicator plots several linear regression channels on the price chart. Each channel can be hidden or drawn as a channel, bands, or both, and its lookback is anchored to price, volume, oscillator extremes, calendar periods, sessions, or corporate events. P
This indicator generates intraday trading signals by combining dual-sigma standard deviation bands, Heikin Ashi candle vectors, and a four-bar confluence score. It triggers long and short signals during defined trading sessions using either mean-reversion boun
Gold Dominator Pro is a multi-indicator overlay designed primarily for gold trading. It combines higher-timeframe exponential moving averages with momentum oscillators like RSI, MACD, and StochRSI, alongside volatility tools such as ATR, Bollinger Bands, and A
This indicator overlays linear regression candles and a UT Bot style ATR trailing stop on the price chart. When linear regression is enabled, open, high, low and close are replaced by regression values, and rising candles are green while falling candles are re