Market regime detector
Labels each bar 0 to 4 as calm, crash, decline, breakdown or choppy; at default settings it reads 0 all session.
The indicator sorts each bar into one of five regimes using the close, a 14-bar ATR, a 14-bar ADX and a 14-bar RSI. Volatility is ATR divided by price, checked against fixed fractions; trend is the ADX value; panic is RSI. Codes 1 to 3 also need a downtrend, meaning minus DI above plus DI, but the default wiring passes only the ADX value, so that test is always false.
How to read it
- The line sits in its own pane below the price and only takes whole values from 0 to 4.
- At default settings it stays at 0 for the whole session; a flat line is the expected reading, not a fault.
- Codes 1 to 3 cannot appear with the default inputs. Code 4 needs the high-volatility line lowered first (see the presets).
- The first bars show nothing while the indicators warm up, about 0.13 percent of bars.
What it outputs
- Regime
- Regime code per bar: 0 consolidation, 1 panic crash, 2 steady decline, 3 breakdown, 4 choppy. Reads 0 on every bar at default settings.
Settings
- extreme_vol_threshold
- Normalized ATR above this is extreme volatility, which splits code 1 from code 2. Raising it makes panic crash (1) rarer and steady decline (2) more common; lowering it does the reverse. Both need a downtrend, so at default inputs nothing changes visibly.
- high_vol_threshold
- Normalized ATR above this is high volatility. Raising it makes choppy (4) and steady decline (2) rarer; lowering it makes them common. The default 1.5 percent of price is far above one-minute ATR, so choppy never shows. Try 0.0002 to see it.
- low_vol_threshold
- Normalized ATR below this is low volatility, used only by code 3 (breakdown). Raising it widens that band; lowering it narrows it. Code 3 needs a downtrend, so nothing visible changes at default inputs.
- strong_trend_threshold
- ADX above this counts as a strong trend, used by codes 1 and 2. Raising it demands a stronger trend before those codes fire; lowering it lets weaker trends count. Those codes need a downtrend, so at default inputs nothing visible changes.
- weak_trend_threshold
- ADX below this counts as a weak trend. Weak trend with high volatility gives choppy (4), and weak trend blocks breakdown (3). Raising it makes choppy more frequent and breakdown rarer; lowering it does the reverse.
- panic_rsi_threshold
- The RSI level below which code 1 (panic crash) can fire. Raising it makes panic easier to trip; lowering it makes it rarer. Code 1 also needs extreme volatility and a downtrend, so at default inputs nothing visible changes.
Pitfalls
- At default settings the indicator reads 0 on every bar. One-minute ATR is about 0.02 percent of price, far below the 1.5 percent high-volatility line, and the ADX input has no DI lines, so downtrend is always false.
- RSI is compared on a 0 to 100 scale, and values under 1 are multiplied by 100 first. The catalog RSI runs -1 to +1, so the panic test (below 30) is really RSI below 0.3, which is true on most bars.
- Compiled runs pick the downtrend rule from the type of the ADX input, not from the value it gets, so they may disagree with the Python results. This was not checked.