Skip to Content
Lookup TraderBar Features & Pattern Tagging

Bar Features & Pattern Tagging

One row per closed candle: causal context, forward outcome, chart shape, and pattern tags. /base-rate and the replay chart read the store; without it they return no_signal rather than erroring.

Build

python3 scripts/build_bar_features.py --symbol XAUUSD --timeframe H1

Incremental by default — re-running only rebuilds bars whose forward window has since elapsed. Pass --rebuild to rewrite every bar, --dry-run to inspect without writing.

If a candle changed

Start the range at least max(feature_horizons) bars before the changed candle, not at it. A bar’s row describes what happened after it, so a corrected candle invalidates the forward half of every one of the 48 bars leading up to it — and the row immediately before it also stores that candle’s open as next_open. Rebuilding from the changed bar itself leaves those stale:

python3 scripts/build_bar_features.py \ --symbol XAUUSD --timeframe H1 --from 2026-03-30 --rebuild

After a bar_feature_version bump

The version lives in server/app/config.py. Every runtime query filters on version equality, so the existing store goes invisible until a full rebuild finishes. Delete the partition tree first — the writer merges on timestamp, and rows left from the old version would survive the merge missing the new columns:

rm -rf data/features/symbol=XAUUSD/timeframe=H1

then rebuild and restart the API. Because the version is read at import time, a running process serves one version consistently for its lifetime; there is no half-migrated state as long as the deploy does not restart mid-rebuild.

The store is a build artifact — everything derives from data/candles, so a changed threshold is a rebuild rather than a migration.

Pattern tagging

Every closed candle is tagged by deterministic code in server/app/taggers/. Tags are causal: detectors see only bars at or before the anchor.

FamilyTags
Candlestickbull_engulfing, bear_engulfing, pin_bar_long, pin_bar_short, inside_break
Confirmed pivotsdouble tops/bottoms, head-and-shoulders and inverse, ascending / descending / symmetrical triangles, rising/falling wedges, broadening formations

Stored on the bar: bar_tags, tag_setup_ids, tag_primary_setup_id, tag_count. /context serves them from the store and falls back to computing on request when the bar is not in it (unbuilt symbol, or history before warmup). tag_source says which path ran.

Confidence vs probability

confidence is match quality — how good an example of the pattern this bar is — on a [0.6, 1.0] scale. It is not a probability that the trade works; that is what /base-rate answers.

/base-rate

Can condition on a current complete pattern with tag_setup_id=...&tag_state=complete; forming patterns are excluded by default. Automatic base-rate recommendations enforce LOOKUP_BASE_RATE_MIN_SAMPLES (default 200) and cannot be lowered by a client request.

The review script emits both an HTML gallery and a machine-readable JSON verdict template with aggregate counts.

Out of scope (tagging)

LLM/Claude tagging and model distillation have been retired: pattern identity is kept deterministic and rebuildable.

Last updated on