Rolling Hurst Exponent
The Hurst exponent classifies a price series on a single scale: near 0.5 behaves like a random walk, above 0.5 shows persistence (moves tend to keep going), below 0.5 shows anti-persistence (moves tend to reverse). Deciding whether to run a trend-following or a mean-reversion approach on a given instrument is exactly this question, and it is usually answered by feel rather than evidence. The classic shortcut computes rescaled range (R/S) on one window and reads the exponent off a single log(R/S) versus log(n) point extended from the origin - a method known to carry a small-sample bias. This indicator instead computes R/S at three related scales (a window, half that window, and a quarter of it) and fits the least-squares slope of log(R/S) against log(n) across the three points. That slope is the Hurst exponent, and using three points rather than one is the standard correction for the single-scale method's bias, while staying cheap enough to recompute on every closed bar. Notes and limitations - Three points give a much better estimate than one, but this is still a small-sample regression, not the full multi-scale Hurst analysis used in academic work with dozens of window sizes. - The exponent can read outside the theoretical 0..1 range on noisy data; the indicator does not clamp it, since clamping would hide exactly the instability worth noticing. - A short InpLookback makes the quartered scale very small and the whole estimate correspondingly noisier - the input validation enforces a floor of 32 bars, but meaningfully stable readings want considerably more history than that. - This describes a statistical property of recent price behaviour. It is not a trade signal and does not predict the direction of the next move even when persistence is high.
Indicator · MT5 · v1.0 · Free
About Rolling Hurst Exponent
Rolling Hurst Exponent is an indicator for MetaTrader 5. It has 1 setting, such as Lookback. MQL source code included.
Files in the download: HurstExponentRolling.ex5, HurstExponentRolling.mq5, HurstExponentRolling.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Lookback | 128 | Largest R/S window, bars (halved and quartered for the other two scales) |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: Trend · MT5 Indicator · MQL5 Source Code