OPEN-SOURCE SCRIPT

ATR Regime Study [CHE]

190
ATR Regime Study [CHE] — ATR percentile regimes with clear bands, table and live label

Summary

This study classifies volatility into five regimes by converting ATR into a percentile rank over a rolling window, plotted on a standardized scale between zero and one hundred. Colored bands mark regime thresholds, while a compact table and an optional label report the current percentile and regime. The standardized scale makes symbols and timeframes easier to compare than raw ATR values. Implemented in Pine v6 as a separate pane (overlay set to false), it is a context tool to adapt tactics and risk handling to the prevailing volatility environment.

Motivation: Why this design?

Raw ATR varies with price scale and asset characteristics, which makes regime comparison inconsistent and leads to poor transfer of settings across symbols and timeframes. The core idea is to transform ATR into a percentile rank within a user-defined lookback, then map it into discrete regimes. This yields a stable, interpretable context signal that shifts slower than raw ATR while still responding to genuine volatility changes.

What’s different vs. standard approaches?

Reference baseline: Traditional ATR plots or ATR bands using fixed multipliers.
Architecture differences:

Percentile ranking of ATR within a rolling window.
Five discrete regimes with fixed thresholds at ninety, seventy, thirty, and ten.
Visual fills between thresholds plus a live table and a last-bar label.
Practical effect: You read a single normalized line between zero and one hundred with consistent thresholds. This improves cross-asset comparison and makes regime shifts obvious at a glance.

How it works (technical)

The script computes ATR over a configurable length, then converts that series to a percentile rank over a configurable number of bars. The percentile is naturally scaled and limited between zero and one hundred. That value is mapped to one of five regimes: above ninety (Extreme), between seventy and ninety (Elevated), between thirty and seventy (Normal), between ten and thirty (Calm), and below ten (Squeeze). Horizontal guide lines mark the thresholds, and fills shade the regions. A table is created once and updated on each bar to show regime definitions and highlight the current row. An optional label on the last bar displays the current percentile and regime. No higher-timeframe requests are used, so repaint risk is limited to normal live-bar fluctuation until the bar closes.

Parameter Guide

ATR length — Effect: Controls how fast ATR reacts to new ranges. Default: fourteen. Trade-offs/Tips: Increase to reduce noise in choppy markets; decrease to react faster during regime changes.
Percentile window (bars) — Effect: Number of bars used for the percentile ranking. Default: two hundred fifty-two. Trade-offs/Tips: Larger windows stabilize the percentile but slow adaptation after structural regime shifts; smaller windows adapt faster but may flip more often.
Table › Show — Effect: Toggles the regime overview table. Default: enabled. Trade-offs/Tips: Disable on constrained layouts to reduce visual clutter.
Table › Position — Effect: Anchors the table in a chart corner. Default: Top Right. Trade-offs/Tips: Choose a corner that avoids overlapping other panels or drawings.
Label › Show — Effect: Toggles a last-bar label with current percentile and regime. Default: enabled. Trade-offs/Tips: Useful for quick reads; disable if it obscures other annotations.

Reading & Interpretation

The white line shows ATR percentile between zero and one hundred. Crossing above seventy signals an elevated volatility environment; above ninety indicates event-driven extremes. Between thirty and seventy represents typical conditions. Between ten and thirty indicates calm conditions that often suit mean reversion. Below ten reflects compression, where breakout probability often increases. The colored bands visually reinforce these ranges. The table summarizes regime definitions and highlights the current state. The last-bar label mirrors the current percentile and regime for quick inspection.

Practical Workflows & Combinations

Trend following: Prefer continuation tactics when the percentile holds in the Normal or Elevated bands and structure confirms higher highs and higher lows. Consider wider stops and partial position sizing as percentile rises.
Mean reversion: Favor fades in Calm regimes within defined ranges; use structure filters and time-of-day constraints to avoid low-liquidity whipsaws.
Breakout preparation: Track compressions below ten; plan entries only with structure confirmation and risk caps, since compressions can persist.
Multi-asset/Multi-TF: Defaults travel well on daily charts. For intraday, reduce the percentile window to align with session dynamics. Combine with trend or market structure tools for confirmation.

Behavior, Constraints & Performance

Repaint/confirmation: The percentile updates during live bars and stabilizes on close; closed bars do not repaint.
security/HTF: Not used. If you add higher-timeframe aggregation externally, account for standard repaint caveats.
Resources: Declared maximum bars back is two thousand; limits for lines and labels are five hundred each. A short loop updates the table rows; arrays are used for table content only.
Known limits: Regime boundaries are fixed; assets with persistent volatility shifts may require window retuning. Low-liquidity periods and gaps can produce abrupt percentile changes. ATR is direction-agnostic and should be paired with trend or structure context.

Sensible Defaults & Quick Tuning

Start with ATR length fourteen and percentile window two hundred fifty-two on daily charts.

Too many flips: Increase ATR length or increase the percentile window.
Too sluggish: Decrease the percentile window or reduce ATR length.
Intraday noise: Keep ATR length moderate and reduce the window to a session-appropriate size; optionally hide the label to declutter.
Compressed markets: Maintain defaults but rely more on structure and volume filters before acting.

What this indicator is—and isn’t

This is a volatility regime context layer that standardizes ATR into interpretable regimes. It is not a complete trading system, not predictive, and not a stand-alone entry signal. Use it alongside structure analysis, confirmation tools, and disciplined risk management.

Disclaimer

The content provided, including all code and materials, is strictly for educational and informational purposes only. It is not intended as, and should not be interpreted as, financial advice, a recommendation to buy or sell any financial instrument, or an offer of any financial product or service. All strategies, tools, and examples discussed are provided for illustrative purposes to demonstrate coding techniques and the functionality of Pine Script within a trading context.

Any results from strategies or tools provided are hypothetical, and past performance is not indicative of future results. Trading and investing involve high risk, including the potential loss of principal, and may not be suitable for all individuals. Before making any trading decisions, please consult with a qualified financial professional to understand the risks involved.

By using this script, you acknowledge and agree that any trading decisions are made solely at your discretion and risk.

Best regards and happy trading

Chervolino

Отказ от ответственности

Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.