Files
nt8-sdk/TASK_GAP059_ORB_RANGE_TELEMETRY_PROMPT.md
mo 7e82b2ce5a [GAP-059]: ORB range telemetry context complete
- SimpleORBNT8.cs: source telemetry ORB range from SDK opening range tracker

- SimpleORBNT8DefaultsTests.cs: guard against dead adapter ORB fields and verify SDK source

- OrbConfluenceFactorTests.cs: prove realistic ORB range ticks produce ratio reason

- SPRINT_BOARD.md and decisions.md: record implementation and deploy blocker

Build: clean | Tests: 545 passing; Core 456 passing | Dual-deployed: no - NinjaTrader.exe PID 18800 locked NT8.Core.dll
2026-08-25 10:10:27 -04:00

6.6 KiB

TASK: GAP-059 — Telemetry OrbRangeVsAtr always reports "no daily bar context"

Staged: 2026-08-23/24 (found during live post-compile SIM validation of GAP-049)

Sprint: Stage 1 — housekeeping, zero trading-behaviour risk (observability only)

Owner: Kilocode

─────────────────────────────────────────────────────────────────

THE DEFECT

OrbRangeVsAtrFactorCalculator.Calculate() (FactorCalculators.cs ~612-622) requires intent.Metadata["orb_range_ticks"] to be present; otherwise it returns the neutral fallback and the reason string "No daily bar context available".

GAP-049 (this session, commit a005dee) added the code that's supposed to supply that key for STATE: telemetry:

metadata.Add("daily_bars", telemetryDaily);
if (telemetryDaily.OrbRangeTicks > 0.0)
    metadata.Add("orb_range_ticks", telemetryDaily.OrbRangeTicks);

telemetryDaily.OrbRangeTicks is a straight copy of whatever _strategyConfig.Parameters["daily_bars"].OrbRangeTicks already held. That source is rebuilt every bar in SimpleORBNT8.OnBarUpdate() (~168-183):

double orbHigh = _openingRangeHigh;
double orbLow = _openingRangeLow;
double orbRangeTicks = 0.0;
if (orbHigh > orbLow) { ... }
DailyBarContext dailyContext = BuildDailyBarContext(_lastSignalDirection, orbRangeTicks, (double)Volume[0]);
_strategyConfig.Parameters["daily_bars"] = dailyContext;

_openingRangeHigh and _openingRangeLow (declared ~108-109) are declared and read but never assigned anywhere in this file. They are permanently 0.0, so orbHigh > orbLow is always false, orbRangeTicks is always 0.0, and GAP-049's > 0.0 guard never passes. The telemetry fix itself is correct — the value it depends on has been dead since before this session.

RUNTIME PROOF — live SIM, 2026-08-23/24

session_20260823_230519.log, every STATE_DETAIL line from 08:29 ET through at least 10:49 ET (i.e. well past the 09:30-10:00 ORB window):

OrbRangeVsAtr="No daily bar context available"

while the same lines' STATE_CONTEXT confirms the real opening range is fully formed:

STATE_CONTEXT: OrbHigh=29243.00 OrbLow=28946.75 OrbWindowStart=09:30 OrbWindowEnd=10:00 OrbReady=True

WHERE THE CORRECT VALUE ALREADY LIVES

SimpleORBNT8.cs already reads the real, live opening range correctly in three other places in the same file, all from the SDK-side ORB tracker:

sdkOrb.OpeningRangeHigh / sdkOrb.OpeningRangeLow / sdkOrb.OpeningRangeReady
  • ~355-360: builds STATE_CONTEXT: OrbHigh=/OrbLow= from these fields (confirmed this is what the live log's correct OrbHigh/OrbLow come from).
  • ~565-569: an existing, separate orbRangeTicks computation already uses exactly this pattern: Math.Round((sdkOrb.OpeningRangeHigh - sdkOrb.OpeningRangeLow) / tickSize).

_openingRangeHigh/_openingRangeLow appear to be superseded/legacy fields that were never finished being wired up (or never removed after the SDK-side tracker took over). Confirm this reading is correct before changing anything — search the whole file and its base class for any other writer of these two fields that a plain grep might have missed.

SCOPE — confirm, do not assume

_strategyConfig.Parameters["daily_bars"] is read in exactly one place in SimpleORBNT8.cs: the telemetry-building code GAP-049 added (BuildStateTelemetryIntent). Real trade-signal scoring appears to get its daily/ORB context a different way (inside SimpleORBStrategy/ AttachDailyBarContext()), not through this dead-field path — meaning this defect is very likely telemetry-only and does not affect real signal grading, sizing, risk, or order submission. Verify this by reading the actual call sites rather than trusting this summary — if real trade scoring does share this broken path, that changes this task's priority significantly and should be reported back before proceeding with the telemetry-only fix below.

THE CHANGE

In SimpleORBNT8.OnBarUpdate() (~168-183), replace the orbHigh/orbLow source with the SDK-side tracker, matching the existing pattern at ~565-569:

SdkSimpleORB sdkOrb = _sdkStrategy as SdkSimpleORB;
double orbHigh = (sdkOrb != null && sdkOrb.OpeningRangeReady) ? sdkOrb.OpeningRangeHigh : 0.0;
double orbLow = (sdkOrb != null && sdkOrb.OpeningRangeReady) ? sdkOrb.OpeningRangeLow : 0.0;

(Adjust to match whatever null/readiness guard style the ~355-360/~565-569 call sites already use — reuse their exact pattern rather than inventing a new one.)

Once confirmed genuinely dead (no other writer found anywhere), remove the _openingRangeHigh/_openingRangeLow fields entirely in the same change — don't leave unused fields that look like they matter.

DO NOT

  • Do not change OrbRangeVsAtrFactorCalculator's scoring logic — it is correct; it just isn't receiving data.
  • Do not change GAP-049's CloneDailyBarContextForTelemetry logic — its > 0.0 guard is correct once the upstream value is real.
  • Do not touch real trade-signal generation, sizing, risk, or order submission — this is a telemetry data-source fix only, unless the Scope check above finds otherwise, in which case stop and report back first.

TESTS (required)

  1. A test proving SimpleORBNT8.OnBarUpdate() (or whatever seam exists) populates orb_range_ticks metadata with a nonzero value once sdkOrb.OpeningRangeReady is true and OpeningRangeHigh > OpeningRangeLow — mirroring the pattern already used for GAP-049's other tests in SimpleORBNT8DefaultsTests.cs if no execution seam exists (source-text assertion is acceptable here for the same NinjaScript-instantiation reason as GAP-049, but say so explicitly rather than silently reusing the pattern without noting the limitation).
  2. A test proving OrbRangeVsAtrFactorCalculator returns a non-neutral, non-"no context" result when fed a daily_bars/orb_range_ticks pair built from realistic ORB high/low values (can likely extend or mirror the existing OrbConfluenceFactorTests.cs patterns from GAP-049).

VALIDATION (operator)

Live/SIM only, after manual NT8 compile. Confirm a STATE_DETAIL line taken after OrbReady=True in STATE_CONTEXT no longer reads OrbRangeVsAtr="No daily bar context available" and instead reports a real ratio-based reason.

GOVERNANCE

Track as [GAP-059] in SPRINT_BOARD.md. Update docs/00-governance/decisions.md DEC-20260823-05 status to implemented with an implementation note on completion. Reference: this task, DEC-20260823-05, session_20260823_230519.log.