OPEN-SOURCE SCRIPT

Hurst Regime Sentinel [JOAT]

474
HURST REGIME SENTINEL [JOAT]

A proper R/S Hurst-exponent regime classifier — the single most respected statistical test for "is this market trending, mean-reverting, or random?". On top of the textbook R/S analysis, the Sentinel adds a five-class regime taxonomy (Strong MR, MR, Random, Trend, Strong Trend), a confirmation-bars filter to suppress flicker, a right-side floating Hurst badge, a regime-tinted background, and — uniquely — a Suggested JOAT Indicator dashboard row that names the best-fit companion script in the JOAT suite for the current regime.

snapshot

The Hurst exponent, properly

The Hurst exponent H is a number between 0 and 1 that characterises the long-run persistence of a time series:

  • H < 0.5 — anti-persistent / mean-reverting. The series tends to reverse its recent direction.
  • H = 0.5 — random walk (Brownian motion). No memory.
  • H > 0.5 — persistent / trending. The series tends to continue its recent direction.


The classical estimator is R/S analysis (rescaled range): split the window into sub-segments, compute the range of cumulative deviations from each sub-mean, normalise by the sub-stdev, average, and fit a log-log slope. This script implements that estimator over a configurable lookback (default 100, the canonical value), with optional log-return source for theoretical correctness, and an EMA smoother on top of the raw H series to give a stable regime read.

Five-class regime taxonomy

The Sentinel does not just classify into trend/MR/random — it sub-classifies the trend and MR sides:

  • Strong MR — H below the strong-MR boundary (default 0.30). Severely anti-persistent. Aggressive reversion regime.
  • MR — H between strong-MR and the MR upper (default 0.40). Mean-reverting.
  • Random — H between MR upper and trend lower (default 0.55). No statistical edge from persistence assumptions.
  • Trend — H above trend lower. Trending.
  • Strong Trend — H above the strong-trend boundary (default 0.65). Strongly persistent. Aggressive momentum regime.


A Minimum-bars-to-confirm filter (default 3 bars) suppresses regime flicker; a change must persist this many bars before it is committed.

Suggested JOAT Indicator row (unique)

The dashboard exposes a Suggested Indicator row that names the best-fit companion script from the JOAT suite for the current regime. The user can pick which suggestions appear (defaults: Volatility Reversion Bands Pro for MR, Quantum Trend Matrix for Trend, Liquidity Magnet Pro for Random — but every other JOAT indicator is selectable). This converts the abstract regime read into a concrete next action: when the regime changes, the script tells you which other tool in the suite to put on the chart.

Visual system

  • Right-side floating label — anchored N bars to the right of the latest bar with current H value, regime, and sub-class.
  • Regime-change labels — drawn at the bar where a confirmed regime change occurs.
  • Background tint by regime — violet for MR, teal for Trend, untinted for Random. Strong sub-classes use a stronger (lower-transparency) alpha than mild sub-classes. Both alphas are configurable.
  • Optional Hurst line companion — when enabled, plots the H series scaled to a configurable fraction of the visible price range. Use to visually track H movement over time. Off by default for a clean chart.
  • Optional reference levels at 0.40 / 0.50 / 0.55 when the line is shown.


A locked Mystic palette (teal trend / violet MR / white random on a midnight-blue ground) gives the chart a distinctive structural identity.

Dashboard

Monospaced table positionable to any of nine corners. Surfaces:

  • Current H value (raw and smoothed).
  • Regime classification with glyph.
  • Sub-class (Strong MR / MR / Random / Trend / Strong Trend).
  • Bars in current regime.
  • Distance from H to nearest threshold.
  • Suggested JOAT Indicator row (toggleable).
  • Source series in use (Close / HL2 / HLC3 / OHLC4 / Log Returns).


snapshot

Alerts

Multiple alert conditions, each independently controllable:

  • Regime changed to MR / Random / Trend
  • Sub-class changed to Strong MR / Strong Trend
  • H crosses 0.50 (random-walk centre)


How to read it

Three reads, in order of conviction:

  1. Sub-class entry (Strong MR or Strong Trend) — the highest-conviction read. The market has decisively committed to a persistence regime; the suggested companion indicator becomes high-conviction.
  2. Regime change confirmed (after the minimum-bars filter) — meaningful enough to switch toolkits. If you were trading momentum and the script now reads MR, your edge has just rotated.
  3. H crossing 0.50 — the structural fault line. Above, persistence is positive; below, it is negative. Even without a sub-class entry, a clean cross of 0.50 is a regime warning.


Suggested settings

Defaults (lookback 100, EMA smoothing 14, MR upper 0.40, trend lower 0.55, strong boundaries 0.30 / 0.65) are tuned for daily and 4H charts on liquid markets — the timeframes where R/S analysis is statistically most meaningful. For 1H and below the indicator works but the H estimate becomes noisier; raise the EMA smoother to compensate. For very long horizons (1W+) increase lookback to 200.

Originality / what's reused

The R/S Hurst estimator is the textbook 1951 method — public-domain statistics, implemented from the original Hurst paper. The implementation here — the bounded-loop R/S computation with sub-segment averaging, the five-class regime taxonomy with strong sub-classes, the confirmation-bars regime-change filter, the regime-driven background tint with mild/strong alpha tiers, the optional scaled Hurst-line overlay, the right-side floating badge, and the suggested-JOAT-indicator dashboard row — is JOAT-original. No third-party code reused.

Open source

Published open-source under the default Mozilla Public License 2.0. The R/S loop, the regime classifier, the suggested-indicator router, and the dashboard are isolated modules. Forks welcome with credit.

Limitations

Hurst R/S is statistical — it describes the recent past, it does not predict the future. The estimator carries the natural noise of finite-sample R/S; the EMA smoother is there to suppress flicker but cannot eliminate underlying noise on short lookbacks. The "Suggested JOAT Indicator" row is a heuristic mapping from regime to tool, not a prediction that any specific signal from that tool will fire — it tells you which corner of the toolkit to look at; the tool itself tells you when to act.



-made with passion by jackofalltrades

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.