Indicator · Pine Script v6 · On the chart

Taught to Trade - Regime Tercile Dashboard

by obekheet

This indicator classifies each bar into a low, middle, or high volatility regime by comparing ATR as a percentage of close with the 33rd and 67th percentiles of that measure over a rolling sample window.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code115
Settings6inputs
LicenceMPL-2.0
Last update12 days ago16 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

115 lines of Pine Script v6 from scripts/regime-tercile-dashboard.pine, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

regime-tercile-dashboard.pine
//@version=6
// Taught to Trade - Regime Tercile Dashboard
// Splits the sample window into low, middle and high volatility thirds.
// No buy/sell signals. Alerts are yours to configure.
indicator("Taught to Trade - Regime Tercile Dashboard", shorttitle = "TT REGIME", overlay = true, max_bars_back = 1000)

grpM = "Measurement"
atrLen   = input.int(14, "ATR length", minval = 2, group = grpM)
lookback = input.int(500, "Sample window (bars)", minval = 60, maxval = 1000, group = grpM)

grpV = "Chart"
shadeBg  = input.bool(true, "Shade the background by regime", group = grpV)
shadeAmt = input.int(88, "Shading transparency", minval = 60, maxval = 98, group = grpV)

grpT = "Table"
posIn = input.string("Top right", "Position", options = ["Top right", "Top left", "Bottom right", "Bottom left"], group = grpT)
szIn  = input.string("Small", "Text size", options = ["Tiny", "Small", "Normal"], group = grpT)

atr    = ta.atr(atrLen)
atrPct = close > 0 ? atr / close * 100.0 : na
p33 = ta.percentile_linear_interpolation(atrPct, lookback, 33)
p67 = ta.percentile_linear_interpolation(atrPct, lookback, 67)

reg = na(atrPct) or na(p33) or na(p67) ? -1 : atrPct <= p33 ? 0 : atrPct <= p67 ? 1 : 2
cls = reg >= 0

rangePct = close > 0 ? (high - low) / close * 100.0 : 0.0
isUp   = close > open
prevUp = close[1] > open[1]
pReg   = nz(reg[1], -1)

cLow  = math.sum(reg == 0 ? 1 : 0, lookback)
cMid  = math.sum(reg == 1 ? 1 : 0, lookback)
cHigh = math.sum(reg == 2 ? 1 : 0, lookback)
total = cLow + cMid + cHigh

rLow  = math.sum(reg == 0 ? rangePct : 0.0, lookback)
rMid  = math.sum(reg == 1 ? rangePct : 0.0, lookback)
rHigh = math.sum(reg == 2 ? rangePct : 0.0, lookback)

uLow  = math.sum(reg == 0 and isUp ? 1 : 0, lookback)
uMid  = math.sum(reg == 1 and isUp ? 1 : 0, lookback)
uHigh = math.sum(reg == 2 and isUp ? 1 : 0, lookback)

pLow  = math.sum(pReg == 0 and prevUp ? 1 : 0, lookback)
pMid  = math.sum(pReg == 1 and prevUp ? 1 : 0, lookback)
pHigh = math.sum(pReg == 2 and prevUp ? 1 : 0, lookback)

bLow  = math.sum(pReg == 0 and prevUp and isUp ? 1 : 0, lookback)
bMid  = math.sum(pReg == 1 and prevUp and isUp ? 1 : 0, lookback)
bHigh = math.sum(pReg == 2 and prevUp and isUp ? 1 : 0, lookback)

regimeChanges = math.sum(cls and cls[1] and reg != reg[1] ? 1 : 0, lookback)
barsInRegime  = ta.barssince(cls and cls[1] and reg != reg[1])
regimeName    = reg == 0 ? "Low" : reg == 1 ? "Middle" : reg == 2 ? "High" : "n/a"

f_safe(float num, float den) => den > 0 ? num / den : na
f_pc(float v)  => na(v) ? "-" : str.tostring(v, "#") + "%"
f_pc2(float v) => na(v) ? "-" : str.tostring(v, "#.##") + "%"

bgcolor(shadeBg and reg == 0 ? color.new(#2F6FED, shadeAmt) : shadeBg and reg == 2 ? color.new(#B3261E, shadeAmt) : na, title = "Regime shading")

tblPos = posIn == "Top left" ? position.top_left : posIn == "Bottom right" ? position.bottom_right : posIn == "Bottom left" ? position.bottom_left : position.top_right
tblSz  = szIn == "Tiny" ? size.tiny : szIn == "Normal" ? size.normal : size.small

bgCol  = color.new(#0E1526, 10)
txtCol = color.new(#E6EAF2, 0)
hdrCol = color.new(#2F6FED, 0)

var table t = table.new(tblPos, 6, 7, border_width = 1, border_color = color.new(#2F6FED, 70))

f_h(int c, string s) => table.cell(t, c, 0, s, text_color = color.white, text_size = tblSz, bgcolor = hdrCol)
f_v(int c, int r, string s) => table.cell(t, c, r, s, text_color = txtCol, text_size = tblSz, text_halign = text.align_right, bgcolor = bgCol)
f_n(int r, string s, color bc) => table.cell(t, 0, r, s, text_color = color.white, text_size = tblSz, text_halign = text.align_left, bgcolor = bc)
f_l(int c, int r, string s) => table.cell(t, c, r, s, text_color = txtCol, text_size = tblSz, text_halign = text.align_left, bgcolor = bgCol)

if barstate.islast
    f_h(0, "REGIME")
    f_h(1, "Bars")
    f_h(2, "Share")
    f_h(3, "Range")
    f_h(4, "Up")
    f_h(5, "Follow")
    f_n(1, "Low vol", color.new(#2F6FED, 35))
    f_v(1, 1, str.tostring(cLow))
    f_v(2, 1, f_pc(f_safe(cLow * 100.0, total)))
    f_v(3, 1, f_pc2(f_safe(rLow, cLow)))
    f_v(4, 1, f_pc(f_safe(uLow * 100.0, cLow)))
    f_v(5, 1, f_pc(f_safe(bLow * 100.0, pLow)))
    f_n(2, "Middle", color.new(#5A6478, 35))
    f_v(1, 2, str.tostring(cMid))
    f_v(2, 2, f_pc(f_safe(cMid * 100.0, total)))
    f_v(3, 2, f_pc2(f_safe(rMid, cMid)))
    f_v(4, 2, f_pc(f_safe(uMid * 100.0, cMid)))
    f_v(5, 2, f_pc(f_safe(bMid * 100.0, pMid)))
    f_n(3, "High vol", color.new(#B3261E, 35))
    f_v(1, 3, str.tostring(cHigh))
    f_v(2, 3, f_pc(f_safe(cHigh * 100.0, total)))
    f_v(3, 3, f_pc2(f_safe(rHigh, cHigh)))
    f_v(4, 3, f_pc(f_safe(uHigh * 100.0, cHigh)))
    f_v(5, 3, f_pc(f_safe(bHigh * 100.0, pHigh)))
    f_n(4, "Now", hdrCol)
    f_l(1, 4, regimeName + " for " + str.tostring(nz(barsInRegime, 0)) + " bars")
    f_l(0, 5, "Regime changes")
    f_l(1, 5, str.tostring(regimeChanges) + " in " + str.tostring(lookback) + " bars")
    f_l(0, 6, "ATR% cutoffs")
    f_l(1, 6, str.tostring(p33, "#.##") + " / " + str.tostring(p67, "#.##"))

enteredHigh = cls and cls[1] and reg == 2 and reg[1] != 2
enteredLow  = cls and cls[1] and reg == 0 and reg[1] != 0
anyChange   = cls and cls[1] and reg != reg[1]

alertcondition(enteredHigh, title = "Entered the high volatility third", message = "Regime Tercile Dashboard: this chart has entered the high volatility third of its sample window.")
alertcondition(enteredLow, title = "Entered the low volatility third", message = "Regime Tercile Dashboard: this chart has entered the low volatility third of its sample window.")
alertcondition(anyChange, title = "Volatility regime changed", message = "Regime Tercile Dashboard: the volatility regime on this chart has changed.")

Overview

Taught to Trade - Regime Tercile Dashboard overlays optional background shading on the price chart and draws a table of bar counts, summed range percentages, up-bar shares, and continuation counts for each tercile, plus how often the regime changes. ATR length, window size, shading, table position, and text size are adjustable. It does not plot entries, exits, or stops.

Details

Published by

obekheet on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Volatility & bands, Screeners & dashboards

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

pine-scriptpinescripttechnical-analysistrading-indicatorstradingviewtradingview-indicators

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
ATR lengthint14atrLen
Sample window (bars)int500lookback
Shade the background by regimebooltrueshadeBg
Shading transparencyint88shadeAmt
PositionstringTop rightposIn
Text sizestringSmallszIn
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.

Similar Pine Scripts

This overlay indicator plots a Supertrend from an ATR length and factor, four exponential moving averages, and a selectable VWAP or TWAP taken from a chosen timeframe on the price chart. It also shows MACD and stochastic with adjustable lengths, smoothing, ver

Indicator v5 Oscillators & momentumMoving averages
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup: Vijay Thakare Option Buying Scalping Setup
330 stars

This multi-symbol indicator evaluates a combined trading condition across up to 40 user-defined symbols. It processes MACD bullish crossovers, RSI thresholds, Bollinger Band boundaries, and DMI/ADX trend filters using security calls. When buy or sell criteria

Indicator v5 Oscillators & momentumVolatility & bands
Updated 2 months ago · None stated GitHub repository of Multi MACD + BB + RSI [Alorse]

Pricing Table

by namuan
318 stars

This indicator calculates theoretical options contract values and in-the-money probabilities using historical realized volatility across multiple standard deviations. It displays these metrics in a table overlay directly on the price chart. Users can adjust th

Indicator v4 Volatility & bandsScreeners & dashboards
Updated 2 months ago · MIT GitHub repository of Pricing Table
218 stars

This indicator maps market structure and supply and demand zones on the price chart. It marks validated and optional unvalidated swing highs and lows using a pivot length and extra confirmation bars. Consolidation and impulse moves are measured against ATR to

Indicator v6 SMC / ICT / price actionSupport & resistance Repaints
Updated 3 months ago · None stated GitHub repository of Market Structure + Supply/Demand
200 stars

Storm Gauge calculates annualized realized volatility and compares it against a historical percentile lookback window to classify market volatility regimes into calm, normal, or storm conditions. Based on a target volatility input, it calculates dynamic positi

Indicator v5 Volatility & bandsScreeners & dashboards
Updated 3 months ago · MIT GitHub repository of Storm Gauge — Vol Regime + Position Size

8zz反指標v2

by hansai-art
121 stars

The 8zz Contrarian Indicator plots reverse sentiment trading signals directly on the price chart based on tracked retail post activity. It generates bullish signals during retail panic and bearish signals during market euphoria. The indicator features adjustab

Indicator v6 Moving averagesOscillators & momentum
Updated 3 months ago · None stated GitHub repository of 8zz反指標v2

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers