Aggiornato

Trend Efficiency Exhaustion Regime-Gated & Calibrated

1 148
Trend Efficiency Exhaustion — Regime-Gated & Calibrated

What it is

A single-pane oscillator that measures when a trend is losing efficiency and turns that into graded, forward-calibrated exhaustion and ignition signals. It is built around one question — "is this efficiency-exhaustion event actually worth acting on?" — and every component in the script exists to answer that one question rather than to add an independent signal.

It plots, in one pane: an efficiency-gap histogram, a fast efficiency line, event markers, a regime "weather-strip" ribbon, and an information table that states the read in plain language. It is symbol- and timeframe-agnostic; defaults are tuned for NIFTY / BANKNIFTY but a Source input and a VIX-symbol input let you use it on any instrument in any market.

The core idea — efficiency, not a magic multiplier

The Efficiency Ratio is the net move divided by the total path travelled over a window: ER = |close − close[n]| / Σ|close − close[1]|, bounded 0–1. A value near 1 means price moved in a straight, efficient line (trend); near 0 means it wandered (chop).

Reading efficiency at two horizons gives the central signal:

Efficiency Gap = ER_fast − ER_slow. When the fast read rolls over while the slow read is still elevated, the trend is losing efficiency under an otherwise intact trend — the classic exhaustion tell.
Displacement percentile ranks the current leg's travel against recent completed legs on this symbol and timeframe, so "stretched" is defined by the instrument's own recent behaviour rather than a fixed price > k·ATR multiplier.

Exhaustion = a stretched leg with fast efficiency rolling over, under a genuine trend. Ignition = fast efficiency surging from a young leg (continuation).

Why these components belong in ONE script (how the mashup works together)

This is a mashup by design, but it is not a stack of indicators each drawing its own signal. Every layer is a gate or a grade on the same event, feeding one decision pipeline:

Efficiency (dual-horizon Efficiency Ratio) — detects the candidate event (exhaustion / ignition).
Regime engine (Efficiency + ADX + a self-exciting volatility-cluster intensity) — decides when the event is even allowed to fire. Exhaustion is only meaningful inside a real trend; it is suppressed in chaotic, news-driven volatility. The regime is rendered as a continuous 5-state read (strong-trend / trend / neutral / reversion / chaos).
Variance ratio (Lo-MacKinlay) — a second, short-window-reliable lens that confirms a real trend existed to exhaust (VR > 1 = trending, < 1 = mean-reverting, ≈ 1 = random walk), with a significance z-statistic.
Ornstein-Uhlenbeck half-life — quality gate: if the estimated mean-reversion half-life is longer than the evaluation horizon, the expected reversion is too slow to pay off in time, so the exhaustion call is rejected.
Implied-volatility (VIX) state — quality gate: exhaustion is more reliable when implied volatility is elevated but stable (fear present, not spiking). The gate blocks exhaustion during a volatility spike.
Divergence quality — grades each exhaustion on the price↔efficiency divergence at the extreme: the slope of the efficiency drop between successive same-side pivots, how developed the swing is, and whether volume waned into the extreme. Weak-divergence setups are filtered out.
Forward calibration — the scorekeeper. Each fired event is logged as a hypothesis and resolved a fixed number of bars later against an ATR-scaled move, then summarised as a realised hit-rate versus an unconditional base rate.


Take any single layer away and the remaining pipeline still describes the same one event — they are complementary measurements of a single hypothesis (a trend running out of efficiency), which is precisely why they belong together rather than as separate scripts. The regime, variance-ratio, OU and VIX layers never plot their own buy/sell calls; they only decide whether the efficiency-exhaustion event is trustworthy.

The part most scripts skip — forward calibration

Most indicators emit a score and never check whether that score was right. Here, every event is queued and resolved N bars later against moveATR × ATR, in R-multiples. The information table reports, per class (Exhaustion / Ignition):


n — resolved sample size
Hit% with a Wilson 95% interval (so you see how stable the rate is)
Base% — the unconditional same-horizon move rate (the honest benchmark)
Edge = Hit% − Base%, marked * when a z-test clears 95%
MFE / MAE in R (how far it ran for you vs against you)
a recency-weighted hit-rate and a regime-conditional hit-rate for the current regime


If Edge is not positive, the signal is not adding information over chance on your chart — and the script tells you so instead of hiding it.

How to use it

Ribbon = context. Don't fade a strong trend; stand aside in chaos.
Histogram rolling over + a marker = the trigger.
Verdict line = the plain-language call (e.g. "TREND · watch for exhaustion", "EXHAUSTION ↓ · fade the up-move (edge +12%*)", "CHAOS · stand aside"), with the calibrated edge appended when the live class is calibrated.
Chart View: Clean (default) shows only the decision elements; Full adds the slow-ER line, displacement %, all reference levels and the divergence glow for analysis.
Information Table: Compact (default) is the key-info panel — verdict, efficiency/displacement/regime, variance-ratio/OU/VIX, best calibrated edge. Pro adds the full per-class calibration table with confidence intervals, recency and regime-conditional rows.

Treat it as a context-and-confirmation overlay on your own process, not an autotrading signal. Paper-trade first and confirm the Edge column is positive on your symbol and timeframe before relying on a class.

Originality

The novelty is not any single formula — those are credited below — but the closed loop: a self-referential displacement percentile (no fixed multiplier), a regime engine and four independent quality gates that all condition one event, and a forward-calibration layer that scores that event against its own base rate with confidence intervals, recency weighting and regime conditioning. Everything is original Pine; no third-party script code is reused.

Inputs, data & markets

Source (group 1) sets the raw series the whole engine reads — change it to use any instrument in any market.
Defaults are tuned for NIFTY / BANKNIFTY; the VIX Symbol defaults to NSE:INDIAVIX. For other markets, change the Source, the ER horizons and the VIX symbol (e.g. CBOE:VIX). A missing VIX symbol auto-disables that gate.
Inputs are organised institutionally: Source & Efficiency · Regime & Variance-Ratio · Displacement · Events · Quality Gates · Calibration · Display · Theme · Exports. The table colour scheme adapts automatically to a light or dark chart background.

Non-repaint

Efficiency is read on confirmed closes, legs are taken from confirmed pivots, events fire on barstate.isconfirmed, and there are no dynamic-length ta.* calls. Forward statistics are in-sample, close-to-close, with no costs, slippage or stops — a study aid, not a backtest.

Concept credits (original Pine re-derivations)

Efficiency Ratio — Perry Kaufman
Variance-ratio test — Andrew Lo & Craig MacKinlay (1988)
ADX / Directional Movement — J. Welles Wilder
Self-exciting (Hawkes) intensity — Alan G. Hawkes (1971)
Mean-reversion half-life — Ornstein & Uhlenbeck process
Score confidence interval — Edwin B. Wilson (1927)
Dominant-cycle homodyne discriminator — John F. Ehlers

Disclaimer

For education and information only. Not financial advice and not a recommendation to buy or sell anything. Past performance does not guarantee future results. The forward statistics are in-sample and idealised (close-to-close, no costs/slippage/stops). Always do your own analysis and manage your own risk; paper-trade before risking real money.
Note di rilascio
v3.0 — REGIME★ backbone, honest out-of-sample harness, and a clearer read

REGIME★: optionally link EXP_Regime from the Market Regime Classifier; the external trend/revert state then drives the event gate instead of this tool re-deriving its own — the shared regime backbone. The internal ER/ADX/VR/Hawkes engine stays as the standalone fallback and still supplies the CHAOS state and the ribbon.
HARNESS+: the calibration adds a uniqueness-weighted EFFECTIVE sample size (overlapping forward windows aren't independent), an IN-SAMPLE / OUT-OF-SAMPLE split — the new OOS line is the one to trust — and a multiple-testing DEFLATED significance bar on the per-class edge.
Visual pass: the efficiency-gap histogram is now a green→red gradient (bright green while momentum builds, red as efficiency fades — the exhaustion tell), the fast-ER line has a glow for prominence, and event markers are colored by expected direction (green ▲ = expect up, red ▼ = expect down; triangles = exhaustion, diamonds = ignition).
On-price signals: every exhaustion / ignition event now also plots on the price chart as a tiny directional triangle — green up (below bar) when the read is bullish, red down (above bar) when bearish.
Added the MPL-2.0 licence header; resolved a conditional stateful ta.* call. New exports: EXP_EdgeOOS, EXP_EffN. The efficiency engine, VR/OU/VIX gates, divergence grading, Wilson calibration, theme and non-repaint behaviour are unchanged.

Descriptive efficiency-exhaustion context; forward statistics are in-sample and out-of-sample, not investment advice.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.