TJ Levels
Key price levels for the chart and the canonical level source for Engine A: session
high/low, VWAP with ±1/2/3σ bands, session volume profile (POC / VAH / VAL), previous-day
levels, naked levels, and swing zones. Version in the chart's indicator list
(TJ Levels vX.Y.Z) always matches _version in Levels.cs.
What it draws
| Group | Series |
|---|---|
| Session H/L | SessionHigh, SessionLow (CME 17:00 CT session model) |
| VWAP | Vwap (Σ typical·vol / Σ vol, typical = (H+L+C)/3) + raw per-bar σ store (VwapStdDev, hidden) |
| VWAP bands | VwapDev1Upper/Lower … Dev3Upper/Lower (multiplier-configurable) |
| Volume | Vah, Val, Poc — intraday volume-profile levels |
| Previous day | PdHigh, PdLow, PdVah, PdVal, PdPoc — flat per session |
| Naked | NakedHigh, NakedLow, NakedPoc — persistent untouched-level magnets |
| Level zones | 11 RangeDataSeries fills (± Zone Width ticks) around every level family |
| Swing zones | Custom-drawn support/resistance blocks + R#/S# markers (no DataSeries behind them) |
Parameter groups
- 1. VWAP —
Show VWAP Levels(master) and per-band show toggles + multipliers for the three σ bands. Multiplier changes do a targeted O(B) rewrite of that band pair (no replay). - 2. Volume —
Show Volume Levels(master: POC/VAH/VAL) andValue Area %(50–95, default 70; changing it forces a recalculation — it changes the data). - 3. Session —
Show Session Levels,Show PD & Naked, andNaked Lookback Sessions(1–20, default 1: how many prior sessions accumulate in the naked queue; depth 1 reproduces the historic roll-overwrite exactly). PD & Naked are a sub-group of Session Levels — with Session Levels off they stay hidden regardless of the PD flag. The PD VAH/VAL/POC trio (and naked POC) belong to the Volume family (they followShow Volume Levels). Visibility toggles are display-only since v0.8.0: every series always carries its real value; hiding a group flips the series' visibility channel (VisualType = VisualMode.Hidefor value series —ValueDataSerieshas noVisiblesetter — andRangeDataSeries.Visiblefor zones) and re-renders. Toggles never affect data,GetLevelsForBar, or Alpha Signal trading output. (v0.11.0: thePresetandIntraday Onlyparameters were REMOVED —Show PD & Nakedtook over the Intraday-Only display role with defaulttrue= the old default rendering;Show Swings & Zonesis the master toggle of the 4. Swing group.) - 4. Swing — swing period left/right,
Include Reversal Candle VA, swing markers (Show Swings,Swing High/Swing Lowpens,Marker Size,Extend Lines Right), zone visuals (Show Zones, support/resistance colors,Allow Overlap,Extend Zones Right,Show Broken Zones,Draw Zone Borders). - 5. Level Zones —
Show Level Zones,Zone Width (ticks)— since v0.11.0 the total band width (width 4 = a 4-tick band) — andZone Opacity %(0–100, default 30) applied to the per-family zone colours. Width changes rewrite only the zone bounds from the stored center lines. - 99. Info —
Show Control Panel(the on-chart HUD master: five group toggle buttons, draggable; when off the HUD never consumes mouse input),Font(v0.12.0 — the HUD's text face/size/style; sub-property edits rebuild the HUD fonts live viaRebuildFonts(), which scales the button font byHUDScaleand keeps the title at scaled + 1 bold),Debug Mode,Calculating Badge Color(v0.10.0), and read-only Version / Copyright / Help / Changelog.
The control-panel HUD (v0.11.0, Market Map parity in v0.12.0)
A middle-top, draggable panel with five group-toggle buttons (VWAP · Volume · Session · PD · Swing) — a button renders in the active colour while its group is on, and PD is de-emphasised while its parent Session group is off (PD & Naked stay a sub-group of Session Levels). Since v0.12.0 the HUD has full Market Map parity:
- Resizable — drag either of the two diagonal corner grips (bottom-left /
bottom-right): the panel's every dimension (base width 240, header, rows, padding,
buttons) derives from the hidden
HUDScaleparameter (0.5–5.0, default 2.0), so the grips resize and rescale the HUD in one operation. The scale persists like the panel position (PanelX/PanelY); it is hidden from the settings grid. - Eye-icon hide — the header's hide control (LEFT of the minimize
−/+button) uses Market Map's eye icon: clicking it hides the panel entirely; bring it back withShow Control Paneloff→on. While visible, the eye marks the open state. - Font setting — the
Fontparameter (99. Info) drives every HUD text element (buttons, title, icons) throughRebuildFonts(). - Guard-first mouse — with the HUD off or hidden, the three
ProcessMouse*overrides returnfalsebefore any state access: chart panning, zoom and crosshair behave exactly as without the indicator. - All HUD setters (groups,
Font,HUDScale, header buttons, drag) are display-only — none callsRecalculateValues()(the P1-1 guarantee).
Value Area (canonical, decision D1)
TJLevels.ComputeSessionVA expands outward from the running POC with two levels of
lookahead per iteration (the next and next-next price level's volume on each side),
ties prefer UP (volUp >= volDn), targeting totalVolume × VaPercent / 100. The
profile is fed once per closed bar (watermark — forming bar excluded, tick re-calls
idempotent) and kept as an incrementally-maintained sorted key list, so the expansion
runs without a per-bar re-sort and the result is cached until the profile next mutates.
ComputeSessionVA runs every bar (truthful-data rule from v0.8.0) — the cached pair
returns on calls where nothing was ingested.
Naked levels (P0-8, decision D7)
- Queue: fixed-capacity ring (≤ 3 kinds × 20 sessions). At each session roll the just-closed session's H/L/POC join the queue; entries older than the lookback are evicted. Persist-until-touched.
- Touch test (per bar): the ±1-tick bar-overlap test (
high >= level − tickandlow <= level + tick) OR the traverse test — previous close on the opposite side while the bar reaches the level (high >= level && prevClose <= level, or the mirror) — so overnight gaps that open past a level kill it even with no bar overlap. - Exposure: the series/struct expose the newest active level per kind, falling back to older queued levels as newer ones are touched (single-value interface — only one magnet per kind is ever visible). Zero = no active level of that kind.
- Exported by TJ Exporter as
NakedPDH/NakedPDL/NakedPDPOC(Full mode).
Previous-day breach lifecycle (known behaviour, not a bug)
A PD level reads 0 after it is breached for the rest of the session: PDH/PDL/VAH/VAL
breach when a bar closes beyond the level, POC breaches on a cross-and-close. The zero
is the level's lifecycle state (it is no longer an active level), not a display effect —
zones collapse with it, and GetLevelsForBar reports 0 exactly when the level is dead.
Flags reset at the next session roll. PD data arrives asynchronously (platform fixed
profile request); the response backfills the elapsed session range on the calc thread.
Swing zones
Fractal swing confirmation (N bars left / N bars right) registers a swing high/low; each
swing creates a resistance/support zone from the trend candle's Value Area (footprint
VA when available, else the candle body box) — optionally widened by the reversal
candle's VA. A zone deactivates when a candle closes beyond its bound; breach flags
are one-way. Zone IDs (R1, R2… / S1, S2…) are assigned at creation. Unless
Allow Overlap is set, a new zone that overlaps an active same-side zone is skipped.
Shared pure cores (single sources — never re-implement)
| Core | Serves |
|---|---|
TJLevels.ComputeValueArea |
TJ Exporter v1.11.0 (SessionVAH/VAL columns) + the indicator's defensive self-heal path. Copy+sort wrapper around the sorted core. |
TJLevels.ComputeValueAreaFromSorted |
The indicator's incremental VA path; the semantic reference for the expansion math. |
TJLevels.ComputeVwapDevBand |
The per-bar series writer and the P1-2 targeted band rewrite (band math cannot drift between them). |
TJLevels.NakedRoll / NakedProcessBar / NakedDerive |
The indicator's naked queue and the Exporter's naked columns. |
TJLevels.TryGetCandleValueArea |
Zone creation and the Exporter's CandleVAH/CandleVAL columns. |
TJLevels.ValidateZonesCore / OverlapsExistingZone |
Zone validation + duplicate detection (work-set lists); also the headless test/benchmark harness. |
TJLevels.IsValidLevelBar / ProfileStepCount |
Bounds and termination guards (pure, test-pinned). |
TJLevels.ZoneHalfWidth / ZoneOpacityAlpha |
The level-zone band width (TOTAL ticks ÷ 2, single source for all 3 write sites) and the Zone Opacity % → alpha mapping (v0.11.0; pure, test-pinned). |
Backtesting/engine/swing_zones.py mirrors the zone lifecycle from the Exporter's
columns; pa_filters.py consumes the exported SessionVAH/VAL. Parity with the Exporter
holds when its Value Area % matches (both default 70).
Embedded mode (Alpha Signal)
Alpha Signal embeds TJLevels as a child (IsEmbedded, SuppressOwnZoneWalk): the
child skips its own zone walk and the parent drives it via WalkZoneStep(bar);
RebuildSessionNow() re-seeds the child's session accumulators after a chart refresh
(ATAS never re-walks an embedded child). The parent's only level read is
GetLevelsForBar(bar) — truthful for any bar regardless of display settings — plus
CopyActiveSupport/ResistanceZones for the zone filter and RenderZoneMarkers for
delegated rendering.
Diagnostics (Debug Mode)
- Per-walk timing — one line per completed recalculation pass, emitted from
OnFinishRecalculate:
TIMING|bars=N|profile=X.Xms|write=Y.Yms (incl. va=Z.Zms)|naked=A.Ams|zones=B.Bms|total=T.Tms
write includes va (measured inside the session-series writer); total is
profile + write + naked + zones (va not double-counted). Zero cost when Debug Mode is
off; one string per finished walk when on.
- Event lines: VWAP|live, VA|live, EVT|SWING, EVT|ZONE_C, EVT|ZONE_S,
EVT|ZONE_B, PD/naked breach lines, session-commit lines.
- CALCULATING... badge (v0.10.0, always on, color-configurable): shown top-left
while a full recalculation walk is in flight (platform recalcs and the six
data-changing setters). Cleared by OnFinishRecalculate, with a self-healing fallback
that clears the badge when the walk reaches its final bar. Costs one bool check per
frame when idle.
Files
TraderJan.Indicators/Levels.cs— the indicator (see_changelogfor history).TraderJan.Tests/TJLevelsTests.cs— D1–D10 NUnit suite (VA golden vectors, naked lifecycle, toggle invariance, bounds, guards).TraderJan.Tests/TJLevelsPerfBenchmark.cs— headless per-stage timing benchmark.- Initiative record:
Projects/_closed/TJ Levels Correctness & Performance/.