Strategy Classifier Divergence

Rosetta stone · reconciles three classifiers + three meanings of "Off-Book" · 2026-05-12

You spotted the VWAP Pull-In · Off-Book dual label on the SOXL trade and called it a contradiction. You were right. This page documents why three classifiers exist, what each one means, where the bugs are, and the canonical formula from the Trader Dale Pine reference.

One-sentence finding: The Python regime_classifier.py has SLOPE_TREND_THRESHOLD = 3.0 with units "degrees" in the docstring, but the canonical Pine indicator computes slope in sigma/bar with a default threshold of 0.05. Same name, different math, different units. Every trade fails the threshold → 0 of 452 trades classified TREND in the 2026-04-21 audit. This is why trend-strategy live evaluation is blocked.

The three "Off-Book"s (terminology drift)

"Off-Book" means three different things depending on which file you're reading. The HUD label collision (VWAP Pull-In · Off-Book) on the SOXL trade was meaning #1 colliding with meaning #2 visually.

#WhereTermActually means
1 strategies-fuzzy.js:141 (HUD modal) Off-Book Entered before 09:30 ET or after 16:00 ET. Off-hours. Has nothing to do with playbook match.
2 regime_classifier.py:276 (EOD scorecard) OFF_BOOK No playbook strategy matched. Auto-F grade. This is the registry-aligned meaning.
3 scorecard_enrichments.py:414 (analytics) off-plan Not on the morning Stocks-In-Play list. Stocks-In-Play discipline check.

Fix: Rename HUD's Off-Book → Off-Hours in strategies-fuzzy.js. Eliminates the visual collision. (HUD-off-limits memory: requires Jim's explicit approval; flagged not patched.)

What strategies-fuzzy.js does (HUD scorecard modal)

Path: Z:\gt_dev\live-accountability-v2\hud\js\strategies-fuzzy.js

Pure JS heuristic. Does NOT consume VWAP, bands, SD offset, or regime. Scores trades 0..1 on four signals:

After scoring, it joins the top-2 labels with · if both clear thresholds (best ≥ 0.28, second ≥ 0.24). That's where VWAP Pull-In · Off-Book comes from — both labels independently crossed their thresholds.

band-blind heuristic Violates the engine/UI separation rule. The fix is to swap this for an API call to classify_v2.py.

What regime_classifier.py does (EOD scorecard)

Path: Z:\setup_daily_reporting\reports\regime_classifier.py

Real band-aware classifier. Reads vwap, vwap_upper_1, band_slope, band_spread_rate from indicator_alerts. Used by gen_scorecard.py at EOD.

The regime detection logic (lines 47-117):

SLOPE_TREND_THRESHOLD    = 3.0    # degrees  <-- BROKEN UNIT
SPREAD_RATE_TREND_MIN    = 30.0   # %
SPREAD_RATE_ROTATION_MAX = 15.0   # %

# Both metrics available:
is_trend    = slope >= 3.0 OR rate >= 30.0
is_rotation = slope <  3.0 AND rate <  15.0

The docstring says "degrees" but the Pine canonical formula produces a sigma/bar ratio. If the TradingView webhook is sending sigma/bar, no trade will ever exceed 3.0. That matches the empirical "0 of 452 trades classified TREND."

unit mismatch Fix: change to Pine-aligned 0.05 sigma/bar (or whatever calibration shows), OR confirm webhook sends degrees and verify the 3.0 value.

The canonical formula (Pine reference indicator)

Path: Z:\trading\indicators\src\indicators\TraderDale_VWAP.pine lines 110-118

Trader Dale's published rules say bands "flat" vs "fanning" determine ROTATION vs TREND. Pine implements this by measuring the slope of the +1σ band normalized to one sigma's worth of price:

// Slope of UB1 over lookback, normalized to sigma/bar
ub1_slope_raw   = (ub1 - ub1[N]) / N        // price change per bar
slope_per_sigma = abs(ub1_slope_raw) / sigma // sigma per bar (unitless ratio)

if slope_per_sigma > trend_slope_thresh    // default 0.05
    regime = ub1_slope_raw > 0 ? TREND_UP : TREND_DOWN
else
    regime = ROTATION

So slope_per_sigma is a unitless number. A value of 0.05 means the band moves 5% of one sigma per bar. Over a 20-bar lookback, that's one full sigma of vertical band travel — the bar-by-bar threshold that distinguishes "bands fanning" from "bands flat."

Pine also returns a 3-state regime: ROTATION / TREND_UP / TREND_DOWN. The Python collapses TREND_UP and TREND_DOWN into single TREND.

canonical math Match this in Python and the TREND tag will start firing.

What classify_v2.py does (the new path)

Path: Z:\setup_daily_reporting\reports\classify_v2.py

Schema-v2 classifier (not yet wired into gen_scorecard.py). Returns exactly ONE strategy_id from /system/strategies.json, or None for off-book. No dual labels possible. Uses band data + regime + extension proxies, NOT hold-time heuristics.

band-aware, schema-aligned Tested 12/12 against synthetic scenarios. Drop-in replacement for classify_entry() once wired.

Concrete example: the SOXL 8:30 short you screenshotted

trade_id 1574339 · SOXL short · entry 182.11 @ 08:30:36 ET · exit 177.80 @ 08:41:22 ET · +$8.62 · HUD says VWAP Pull-In · Off-Book, grade C.

ClassifierWhat it seesVerdict
strategies-fuzzy.js (HUD) 11 min hold → pull-in match (sc=0.76). Entry < 09:30 ET → "Off-Book" off-hours (sc=0.60). Both above 0.28 threshold. VWAP Pull-In · Off-Book (the dual-label bug)
regime_classifier.py (EOD) Pre-RTH bar → band data likely missing or stale. band_slope probably tiny in sigma/bar units. With threshold 3.0 "degrees" → never TREND. Likely tags VWAP_PULL_IN or OFF_BOOK depending on sd_offset availability. probably mis-tagged (unit mismatch + pre-RTH data gap)
classify_v2.py (new) SHORT, regime probably ROTATION (pre-RTH), entry near VWAP/+0.5 SD, no extension story. With v1.1 schema, a "regular_session_only" entry rule would mark this off-book cleanly. vwap-pull-in-short OR off-book — never both

The trade was a clean short fade from above VWAP back through bands. After classify_v2 wiring it would be tagged vwap-pull-in-short with quality grade reduced for pre-RTH entry — not the confusing dual label.

Recommended remediation path

In order of cheapest → biggest unblock:

  1. Calibrate the regime threshold. Export a sample of band_slope values from indicator_alerts for a week. Run regime_classifier_v2.calibrate_threshold(samples). If sample range is 0..0.5 it's sigma/bar (use ~0.05 threshold). If range is 0..90 it's degrees (current 3.0 may be too high; try 1.0).
  2. Swap regime_classifier.py → regime_classifier_v2.py in gen_scorecard.py. Drop-in; same signatures; defaults to Pine-aligned sigma/bar @ 0.05. Risk: changes tonight's scorecard tagging. Run a diff first.
  3. Wire classify_v2.py into gen_scorecard.py classify_entry(). Now every trade gets ONE strategy_id keyed to /system/strategies.json. Dual labels disappear at the data layer.
  4. Rename Off-Book → Off-Hours in strategies-fuzzy.js. Eliminates the visual collision. (HUD-off-limits — requires Jim's by-name approval.)
  5. Eventually replace strategies-fuzzy.js with an API call to a server-side classify_v2.py endpoint. The HUD displays the canonical answer; no UI re-implements grading logic. This is the engine/UI separation rule landing.

Ready-to-use artifacts

FilePurpose
Z:\setup_daily_reporting\reports\regime_classifier_v2.py Drop-in replacement with Pine-aligned sigma/bar formula. slope_units parameter supports both 'sigma_per_bar' (default) and 'degrees' for back-compat.
regime_classifier_v2.calibrate_threshold(samples) Calibration helper. Feed real band_slope samples; returns p50/p75/p80/p90 + recommended threshold + unit inference.
Z:\setup_daily_reporting\reports\classify_v2.py Schema-v2 classifier. 12/12 tests pass. Returns single strategy_id keyed to /system/strategies.json.
/system/strategies.json Canonical registry. 9 strategies, full live-eval arrays. Schema_version 2.

Generated 2026-05-12 · references memory file project_strategy_classifier_divergence.md · Pine source Z:\trading\indicators\src\indicators\TraderDale_VWAP.pine · back to strategy-system.html