OPEN-SOURCE SCRIPT
Higuchi Fractal Dimension [forexobroker]

Higuchi Fractal Dimension estimates the fractal dimension D of the price curve in a bounded [1, 2] interval: D close to 1 means smooth and trending, D close to 2 means jagged and random. The simplified two-scale variant (k = 1 and k = 4) gives a fast, deterministic estimator suitable for live charts.
🔶 ALGORITHM
1. L(1) = average absolute single-bar move over the window: sum |close - close[i+1]| / (N - 1).
2. L(4) = average absolute four-bar move, normalised by step count.
3. Dimension D = log(L(1) / L(4)) / log(4) + 1, clipped to [1, 2].
4. Smooth regime when D <= threshold.
5. Direction comes from close vs trend SMA.
🔶 SIGNAL LOGIC
- Buy: smooth regime AND close > SMA AND close crosses SMA up AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: smooth regime AND close < SMA AND close crosses SMA down.
- Position-lock state machine.
🔶 INPUTS
- Higuchi Window (default 60)
- Trend SMA Length (default 20)
- Smooth Threshold (default 1.65)
- Cooldown Bars (default 4)
- Visual: dashboard, glow, SMA toggle, buy / sell colors
🔶 ALERTS
HFD Buy, HFD Sell, HFD Any Signal, HFD Smooth On, HFD Smooth Off, HFD Strong Trend, HFD Strong Chop, HFD SMA Cross Up, HFD Webhook JSON.
🔶 LIMITATIONS
- Two-scale (k = 1, k = 4) approximation is faster but less accurate than the full Higuchi method (k = 1..k_max).
- D depends on price scale, partly mitigated by ratio formulation; on extremely thin instruments the estimator can saturate.
- Threshold 1.65 is calibrated to liquid majors / indices; faster instruments may need a lower threshold.
- "Random walk" is theoretical D = 1.5; real charts often show D between 1.4 and 1.7 even in clearly trending sessions.
🔶 ALGORITHM
1. L(1) = average absolute single-bar move over the window: sum |close - close[i+1]| / (N - 1).
2. L(4) = average absolute four-bar move, normalised by step count.
3. Dimension D = log(L(1) / L(4)) / log(4) + 1, clipped to [1, 2].
4. Smooth regime when D <= threshold.
5. Direction comes from close vs trend SMA.
🔶 SIGNAL LOGIC
- Buy: smooth regime AND close > SMA AND close crosses SMA up AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: smooth regime AND close < SMA AND close crosses SMA down.
- Position-lock state machine.
🔶 INPUTS
- Higuchi Window (default 60)
- Trend SMA Length (default 20)
- Smooth Threshold (default 1.65)
- Cooldown Bars (default 4)
- Visual: dashboard, glow, SMA toggle, buy / sell colors
🔶 ALERTS
HFD Buy, HFD Sell, HFD Any Signal, HFD Smooth On, HFD Smooth Off, HFD Strong Trend, HFD Strong Chop, HFD SMA Cross Up, HFD Webhook JSON.
🔶 LIMITATIONS
- Two-scale (k = 1, k = 4) approximation is faster but less accurate than the full Higuchi method (k = 1..k_max).
- D depends on price scale, partly mitigated by ratio formulation; on extremely thin instruments the estimator can saturate.
- Threshold 1.65 is calibrated to liquid majors / indices; faster instruments may need a lower threshold.
- "Random walk" is theoretical D = 1.5; real charts often show D between 1.4 and 1.7 even in clearly trending sessions.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
🔵Gain access to our powerful tools : forexobroker.com/tv
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
🔵Gain access to our powerful tools : forexobroker.com/tv
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.