HurstRegime
Trending (1), reverting (-1) or neither (0) from a Hurst estimate; at default settings it reads 1 on almost every bar.
It takes the bar-to-bar changes in the close over the last window bars and measures how their rescaled range (R/S) grows with block size, from 2 bars up to max_lag. The slope of that growth is the Hurst exponent H: 0.5 in theory for a random walk, higher when moves persist, lower when they reverse. H above the trending threshold gives 1, H below the reverting threshold gives -1, and anything between gives 0; the first window bars of the chart stay blank.
How to read it
- The line sits in its own pane below the price and takes whole values: 1 trending, 0 between the thresholds, -1 reverting.
- At default settings on SPY one-minute bars it reads 1 on at least 95% of bars and never reached -1, so a flat line at 1 is the normal picture and says little.
- A drop from 1 to 0 means the estimate fell back under the trending threshold. The reading shows persistence, not the direction of the move.
What it outputs
- Regime
- Whole-number regime from the Hurst estimate: 1 trending, 0 between the thresholds, -1 reverting. Blank for the first window bars.
Settings
- window
- How many recent bars each estimate uses. Raising it gives each reading more bars, so the line moves more slowly and more of the chart's start stays blank. Lowering it reacts faster but uses fewer bars per estimate.
- max_lag
- The largest block size used, capped at window/2 minus 1. Raising it lowers the readings: on random-walk tests with a 100-bar window the median fell from about 0.76 at 20 to about 0.69 at 40. Lowering it keeps the bias that pushes readings toward 1.
- trending_threshold
- Readings above this give 1. Raising it means only stronger persistence counts as trending. At 0.55 nearly every bar qualifies; with the default window, 0.8 kept about one random-walk bar in five as trending.
- reverting_threshold
- Readings below this give -1. At 0.45 it almost never fires, since the estimate rarely falls that low even on random data. Raising it makes -1 more common.
Pitfalls
- The estimate reads trends that are not there. On random-walk test data (true H 0.5) at defaults the median reading was about 0.76 and none fell below 0.55, so the default line sits at 1 with or without a trend.
- On SPY one-minute bars for September 2026 it was 1 on at least 95% of bars and its correlation with close was 0.04, so it is near-constant and does not track price. Tune the thresholds before reading it as a regime call.
- The try presets were checked on random-walk test data, not on SPY. They show where the thresholds split a no-trend series, not whether that split matches real regimes.