OPEN-SOURCE SCRIPT
Fractal Dimension Index [JOAT]

FRACTAL DIMENSION INDEX [JOAT]
A proper Higuchi-method Fractal Dimension Index that tells you whether the market is currently trending (D approaches 1.0 — a smooth, linear path), chopping (D approaches 2.0 — a noisy, plane-filling random walk), or somewhere in between. Unlike volatility, FDI does not care about how much price moved — it cares about how convoluted the path was getting there. That makes it the single cleanest regime-classification number in technical analysis.

What FDI measures
The fractal dimension of a curve is a number between 1.0 (a perfect line) and 2.0 (a curve dense enough to fill a plane). For price series:
The Higuchi-paper canonical thresholds are 1.4 (trend) and 1.6 (chop); both are configurable.
Higuchi algorithm — done properly
The implementation is the standard Higuchi method:
A minimum-valid-pairs guard (default 3) prevents D from being computed when too few (k, L) pairs are finite, and a warmup-bars gate (default 50) prevents wild D values on sparse early data.
Regime classification with hysteresis
Raw D is mapped to one of three regimes — Trending / Random / Chop — using the two-threshold scheme. Two extra alert thresholds (Extreme Trend D < 1.30 and Extreme Chop D > 1.70) flag the high-conviction tail cases.
Visual system
A locked Pastel palette (mint trend / coral chop / cream random on a warm-white ground) gives the indicator a distinctive soft-institutional look.
Dashboard
Monospaced table positionable to any of nine corners. Surfaces:
Alerts
Four alert conditions, each independently controllable:
How to read it
Two reads, in order of conviction:
The single most useful workflow is to use FDI as a meta-filter — pair every signal-generating indicator with FDI regime. Trend signals from a momentum tool become high-conviction when D < 1.4; reversion signals from a Z-score oscillator become high-conviction when D > 1.6. The Suggested JOAT Indicator dashboard rows in Hurst Regime Sentinel and Entropy Oscillator follow exactly this principle.
Suggested settings
Defaults (window 30, k_max 8, EMA smoothing 5, warmup 50) are tuned for 15m–1H. For lower timeframes drop window to 20 and EMA to 3. For HTF (4H+) raise window to 50 and EMA to 8. The Higuchi-paper thresholds (1.4 / 1.6) are intentionally classical — tighten only if you find the regime classification too sensitive on your instrument.
Originality / what's reused
The Higuchi fractal-dimension algorithm is the textbook 1988 method — a public-domain piece of applied mathematics, implemented from the paper. The implementation here — the bounded-loop Higuchi pipeline with minimum-pairs guard and warmup gate, the two-threshold regime classifier with extreme-tail alerts, the pastel-palette regime tint, the pin-to-scale D-line companion logic, the right-side floating label, and the dashboard — is JOAT-original. No third-party code reused.
Open source
Published open-source under the default Mozilla Public License 2.0. The Higuchi loop, the regime classifier, the alert logic, and the dashboard are isolated modules — adapt any single piece without reading the whole file. Forks welcome with credit.
Limitations
Higuchi D is statistical — it tells you about recent path complexity, not future direction. A trending regime (D < 1.4) does not say which way; it says momentum tools should work. Combine with a directional indicator. The algorithm uses bounded Pine loops; very large window values increase compile cost. D is smoothed (EMA-filtered) by default, which trades some lag for substantially reduced flicker; turn smoothing off to see raw D.
—
-made with passion by jackofalltrades
A proper Higuchi-method Fractal Dimension Index that tells you whether the market is currently trending (D approaches 1.0 — a smooth, linear path), chopping (D approaches 2.0 — a noisy, plane-filling random walk), or somewhere in between. Unlike volatility, FDI does not care about how much price moved — it cares about how convoluted the path was getting there. That makes it the single cleanest regime-classification number in technical analysis.
What FDI measures
The fractal dimension of a curve is a number between 1.0 (a perfect line) and 2.0 (a curve dense enough to fill a plane). For price series:
- D ≈ 1.0–1.4 — the price path is close to a straight line. The market is trending; momentum tools work, reversion tools don't.
- D ≈ 1.4–1.6 — the path is in a transitional regime. Use neutral tools.
- D ≈ 1.6–2.0 — the path is chaotic and self-intersecting. The market is chopping; reversion tools work, momentum tools whipsaw.
The Higuchi-paper canonical thresholds are 1.4 (trend) and 1.6 (chop); both are configurable.
Higuchi algorithm — done properly
The implementation is the standard Higuchi method:
- For each k from 1 to k_max (configurable, default 8), compute the average curve length L(k) across k starting offsets, normalised by the window length N.
- Build the k_max pairs (log k, −log L(k)).
- Fit a least-squares line through those pairs; the slope is the fractal dimension D.
- Apply optional EMA smoothing (configurable, default 5 bars) to suppress per-bar jitter.
A minimum-valid-pairs guard (default 3) prevents D from being computed when too few (k, L) pairs are finite, and a warmup-bars gate (default 50) prevents wild D values on sparse early data.
Regime classification with hysteresis
Raw D is mapped to one of three regimes — Trending / Random / Chop — using the two-threshold scheme. Two extra alert thresholds (Extreme Trend D < 1.30 and Extreme Chop D > 1.70) flag the high-conviction tail cases.
Visual system
- Background tint by regime — pastel mint for trend, coral for chop, cream for random. Transparency configurable (default 88, institutional-subtle).
- Regime-change markers — tiny up/down/circle glyphs above price at every confirmed flip.
- Optional candle tinting by regime (off by default to preserve user's chart style).
- Optional D-line companion — when enabled, the smoothed D is plotted as a series. Because the script is overlay, pin the line to its own scale (right-click → Pin to scale → No Scale). For a true sub-pane, add the indicator a second time and drag that instance into a new pane.
- Right-side floating label — anchored N bars right of the live close showing current D and a regime glyph. Configurable size, offset, regime text.
- Optional reference horizontal lines at D = 1.4 / 1.5 / 1.6 when the D-line is shown.
A locked Pastel palette (mint trend / coral chop / cream random on a warm-white ground) gives the indicator a distinctive soft-institutional look.
Dashboard
Monospaced table positionable to any of nine corners. Surfaces:
- Current D value and smoothed D value.
- Regime classification with glyph.
- Bars in current regime.
- Distance to nearest threshold.
- Extreme-state badge when in tail regions.
Alerts
Four alert conditions, each independently controllable:
- Regime Flip (any classification change)
- Extreme Trend (D crosses below 1.30)
- Extreme Chop (D crosses above 1.70)
- D Series Crosses 1.5 (the random-walk centre)
How to read it
Two reads, in order of conviction:
- Regime classification + bars in regime — the more bars the current regime has persisted, the more reliable the read. Brand-new flips can flicker; multi-bar confirmed regimes do not.
- Extreme regime alerts — when D crosses below 1.30, the market is in an extremely directional regime — momentum trades are the highest-conviction setups. When D crosses above 1.70, the market is in pathological chop — fade extremes, do not chase breakouts.
The single most useful workflow is to use FDI as a meta-filter — pair every signal-generating indicator with FDI regime. Trend signals from a momentum tool become high-conviction when D < 1.4; reversion signals from a Z-score oscillator become high-conviction when D > 1.6. The Suggested JOAT Indicator dashboard rows in Hurst Regime Sentinel and Entropy Oscillator follow exactly this principle.
Suggested settings
Defaults (window 30, k_max 8, EMA smoothing 5, warmup 50) are tuned for 15m–1H. For lower timeframes drop window to 20 and EMA to 3. For HTF (4H+) raise window to 50 and EMA to 8. The Higuchi-paper thresholds (1.4 / 1.6) are intentionally classical — tighten only if you find the regime classification too sensitive on your instrument.
Originality / what's reused
The Higuchi fractal-dimension algorithm is the textbook 1988 method — a public-domain piece of applied mathematics, implemented from the paper. The implementation here — the bounded-loop Higuchi pipeline with minimum-pairs guard and warmup gate, the two-threshold regime classifier with extreme-tail alerts, the pastel-palette regime tint, the pin-to-scale D-line companion logic, the right-side floating label, and the dashboard — is JOAT-original. No third-party code reused.
Open source
Published open-source under the default Mozilla Public License 2.0. The Higuchi loop, the regime classifier, the alert logic, and the dashboard are isolated modules — adapt any single piece without reading the whole file. Forks welcome with credit.
Limitations
Higuchi D is statistical — it tells you about recent path complexity, not future direction. A trending regime (D < 1.4) does not say which way; it says momentum tools should work. Combine with a directional indicator. The algorithm uses bounded Pine loops; very large window values increase compile cost. D is smoothed (EMA-filtered) by default, which trades some lag for substantially reduced flicker; turn smoothing off to see raw D.
—
-made with passion by jackofalltrades
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
The AI Trading Ecosystem, Built to win trades 📈
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
The AI Trading Ecosystem, Built to win trades 📈
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Get Full Access 👇
jackofalltrades.vip 🌐
t.me/jackofalltradesvip 🃏
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.