OPEN-SOURCE SCRIPT

Higuchi Fractal Dimension [forexobroker]

380
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.

면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.