Files
nt8-sdk/TASK_00b_PROMPT.md

4.0 KiB

TASK-00b — Chart Diagnostics (Sprint 2.6)

Spec: NT8_SDK_Master_Document_v6.1 — Section 3.2
Depends on: TASK-FIX-01


Read docs/00-governance/active_work.md and SPRINT_BOARD.md before starting.

Implement TASK-00b: Chart Diagnostics — visual on-chart proof of every decision so Gate Run #2 reviewers can see exactly what the strategy saw without opening logs.

WHAT TO BUILD:

1. In NT8StrategyBase.cs (src/NT8.Adapters/Strategies/NT8StrategyBase.cs):
   a. Add [NinjaScriptProperty] bool EnableChartDiagnostics (default = true)
   b. Add protected virtual void DrawDiagnostics(BarData bar, StrategyContext context, StrategyIntent intent)
      - Called from SubmitOrderToNT8 after intent resolved, and from OnBarUpdate for passive display
      - Uses NinjaTrader.NinjaScript.DrawingTools.Draw.* methods
      - C# 5.0: explicit null checks, no ?. operator

   c. Required visual elements (all behind EnableChartDiagnostics):
      i.   ORB Range Box: Draw.Rectangle from _openingRangeStart/_openingRangeHigh to _openingRangeEnd/_openingRangeLow
           Color: semi-transparent blue, tag "ORB_Range"
      ii.  Breakout Arrows: Draw.ArrowUp/Down at breakout bar (long/short trigger)
           Tag: "ORB_Breakout_<trade_seq>"
      iii. ATR Dynamic Stop Line: Draw.Line horizontal at entry ± ATR stop distance
           Color: orange, DashStyle.Dash, tag "ATR_Stop_<trade_seq>"
           Show ONLY when EnableDynamicStop=true AND CurrentBars[0] >= AtrPeriod
      iv.  Resolved RunnerMode Label: Draw.Text at top-right of chart
           Text: "Runner: <Mode1DualLeg/Mode2RunnerOnly/Mode3ScalerOnly/Disabled> (Qty=<N>)"
           Color: green=Mode1, blue=Mode2, gray=Mode3/Disabled, tag "Runner_Mode"
      v.   Regime Indicator: Draw.Text below RunnerMode
           Text: "Regime: <Bullish/Bearish/Neutral> | AVWAP Slope: <slope:F4>"
           Color: green=bullish, red=bearish, gray=neutral, tag "Regime"
      vi.  Session Tag: Draw.Text at session start
           Text: "RTH_ORB | <YYYY-MM-DD> | <Holiday/EarlyClose/Normal>"
           Tag: "Session_Tag"
      vii. Test Mode Banner: Draw.TextFixed at top-center (if TestMode=true)
           Text: "⚠ TEST MODE ACTIVE — NOT LIVE ⚠", large red font, tag "TestMode_Banner"
      viii. Provenance Link: Draw.TextFixed at bottom-right
            Text: "Provenance: provenance_<StrategyName>_<date>.json"
            Tag: "Provenance_Link"

   d. Cleanup: In OnStateChange → State.Terminated, remove all objects with tags above
      (DrawObjects.RemoveAllWithTag("ORB_Range"), etc.)

2. In SimpleORBNT8.cs (src/NT8.Adapters/Strategies/SimpleORBNT8.cs):
   - Override DrawDiagnostics to add ORB-specific:
     - Draw.Line for longTrigger/shortTrigger levels (dashed green/red)
     - Draw.Text for MinTradeGrade threshold on chart

3. In SimpleORBStrategy.cs (src/NT8.Strategies/Examples/SimpleORBStrategy.cs):
   - Add public void DrawDiagnostics(BarData bar, StrategyContext context, StrategyIntent intent, NT8StrategyBase adapter)
     - Called by adapter's DrawDiagnostics
     - Exposes internal state: _openingRangeHigh/Low, _tradeTaken, _dailyTradeCount, regime from context

CONSTRAINTS:
- C# 5.0 only
- Draw.* calls only on primary series (BarsInProgress == 0)
- All tags prefixed with strategy Name to avoid collisions
- Colors: System.Windows.Media.Color or Brushes from NinjaTrader.Gui
- Dual-deploy ALL changed files to NT8 Custom\Strategies\

VERIFICATION:
- .\verify-build.bat ✅
- dotnet test ✅ (492 tests)
- Enable in NT8 SIM on 5-min NQ chart → verify ALL elements appear:
  [ ] ORB blue box at 9:30-10:00
  [ ] Breakout arrows on signal bars
  [ ] Orange dashed ATR stop line at entry ± distance
  [ ] "Runner: Mode2RunnerOnly (Qty=1)" label (when Qty=1)
  [ ] "Regime: Bullish | AVWAP Slope: 0.0023" label
  [ ] "RTH_ORB | 2026-07-13 | Normal" session tag
  [ ] TestMode banner when TestMode=true
  [ ] Provenance file link at bottom-right
- Disable EnableChartDiagnostics=false → verify ALL drawings removed

WHEN DONE: Follow .kilocode/rules/self_learning_loop.md completely (all 6 steps).