$npx -y skills add SKE-Labs/agent-trading-skills --skill market-regime-detectionIdentify current market regime (trending, ranging, squeeze, or volatile) to select appropriate trading strategies. Uses only no-cost indicators (EMA slope, BB Width, ATR Ratio, Donchian) — avoids API-billed indicators like ADX/DMI/Supertrend.
| 1 | # Market Regime Detection |
| 2 | |
| 3 | Regime labels summarize observable trend and volatility states. They are model outputs with uncertainty, not natural market categories; measure whether they add held-out value to the downstream strategy. |
| 4 | |
| 5 | ## Regime Types |
| 6 | |
| 7 | | Regime | EMA Slope (50, 5-bar) | BB Width | Price Action | |
| 8 | | ------------ | --------------------- | --------- | ----------------------------------------- | |
| 9 | | **Trending Up** | Positive normalized slope | Expanding/steady | Objective HH/HL or directional-return state | |
| 10 | | **Trending Down** | Negative normalized slope | Expanding/steady | Objective LH/LL or directional-return state | |
| 11 | | **Ranging** | Near-zero normalized slope | Middle distribution | Oscillation under predeclared rule | |
| 12 | | **Squeeze** | Near-zero normalized slope | Low percentile, optional BB inside KC | Relative compression; direction unknown | |
| 13 | | **Volatile / Chop** | Slope flipping run-to-run | Very wide | Whipsaws both directions | |
| 14 | |
| 15 | ## Detection Inputs (all in the free indicator whitelist) |
| 16 | |
| 17 | **EMA slope candidate** — compute over a predeclared horizon and normalize by price or ATR: |
| 18 | ``` |
| 19 | ema50_slope_pct = (ema50[-1] - ema50[-5]) / ema50[-5] * 100 |
| 20 | ``` |
| 21 | Derive positive, negative, and near-zero bands from training data or rolling historical percentiles for the instrument/timeframe; freeze them before evaluation. |
| 22 | |
| 23 | **BB Width** = `(bb_upper - bb_lower) / bb_middle * 100` — rolling-100-period percentile: |
| 24 | - `> 80th pctl` → expansion, supports a trend read |
| 25 | - `< 20th pctl` → squeeze candidate; no direction or imminent break is implied |
| 26 | - mid-band → ranging |
| 27 | |
| 28 | **ATR Ratio** = `atr_14 / rolling_median(atr_14, 20)`: |
| 29 | Use rolling percentiles or training-set thresholds; ATR ratio measures volatility, not whether price is trending or choppy. |
| 30 | |
| 31 | **BB Inside KC** — if `bb_lower > kc_lower AND bb_upper < kc_upper`, the Bollinger band is inside the Keltner channel → compression. Pair with low BB Width to confirm squeeze. |
| 32 | |
| 33 | **Donchian Position** — `(close - donchian_lower) / (donchian_upper - donchian_lower)`: |
| 34 | - near 0 or 1 with EMA slope agreeing → confirmed trend continuation |
| 35 | - mid-band (0.4–0.6) with flat slope → ranging |
| 36 | |
| 37 | ## Composite Classification |
| 38 | |
| 39 | | EMA Slope | BB Width | ATR Ratio | BB-in-KC | Regime | |
| 40 | | ---------------- | -------- | --------- | -------- | -------------------- | |
| 41 | | Outside trained near-zero band | Expanding | Elevated percentile | No | **Trending candidate** | |
| 42 | | Inside trained near-zero band | Low percentile | Low percentile | Yes | **Squeeze candidate** | |
| 43 | | Inside trained near-zero band | Middle percentile | Middle percentile | No | **Range candidate** | |
| 44 | | Unstable sign | Very high percentile | Very high percentile | No | **Volatile candidate** | |
| 45 | | Mixed | Mixed | Mixed | Mixed | **Transitional/uncertain** | |
| 46 | |
| 47 | The table is a seed specification only. Do not count correlated inputs as independent agreement or map them directly to confidence/size. Calibrate a classifier, report posterior/calibration if available, otherwise report features plus `classified`, `uncertain`, or `no trade`. |
| 48 | |
| 49 | ## Regime Change Signals |
| 50 | |
| 51 | | Signal | Meaning | |
| 52 | | ----------------------------------------------- | -------------------------------------- | |
| 53 | | EMA50 5-bar slope crosses through ±0.15% | Range → trend or trend → range pivot | |
| 54 | | BB Width expansion exceeds trained percentile/rate | Volatility expansion; direction unknown | |
| 55 | | BB Width contracts to <20th pctl + BB inside KC | Squeeze forming | |
| 56 | | ATR Ratio jumps above 1.5x off a low base | Vol expansion, expect direction reveal | |
| 57 | | Price closes outside Donchian-20 boundary | Breakout from prior range | |
| 58 | |
| 59 | ## Strategy Selection Matrix |
| 60 | |
| 61 | | Regime | Use These Skills | Avoid | |
| 62 | | --------------- | --------------------------------------------------- | --------------------------------------- | |
| 63 | | **Trending** | moving-average-crossover, pullback-trading, fibonacci-trading, trailing-stop | mean-reversion, range-trading | |
| 64 | | **Ranging** | mean-reversion, bollinger-bands, supply-demand-zones | momentum-trading, MA crossover | |
| 65 | | **Squeeze** | breakout-trading (arm BOTH directions, wait for break) | range-trading (about to break) | |
| 66 | | **Volatile / Chop** | wider stops, smaller size, prefer to sit out | all trend-following, all mean-reversion | |
| 67 | | **Transitional** | use only strategies validated in this state or wait | untested regime substitution | |
| 68 | |
| 69 | ## Workflo |