NT8-SDK — Visual Pack v7.0

Companion to NT8_SDK_Master_Document_v7.0_Complete.docx · rev B · evidence as of 2026-08-18 · repo C:\dev\nt8-sdk @ f617574

1 · Nine-layer architecture

Layers 1–8 are platform-free. Layer 9 is the only one that imports NinjaTrader. That separation is real and maintained — it is what makes a broker-neutral platform achievable rather than a rewrite. The status column is honest about which layers are actually load-bearing today.

1
Strategy
IStrategy · SimpleORBStrategy · NT8 wrappers
Signal only. Emits StrategyIntent
load-bearing
2
Intelligence
ConfluenceScorer · 10 × IFactorCalculator · GradeFilter
Quality gate before risk
weighting defect
3
Risk
BasicRisk T1 · AdvancedRisk T2/T3/T3.5 · PortfolioRiskManager
Four checkpoints per trade
blocking trades
4
Sizing
BasicPositionSizer · GradeBasedSizer · VolatilityAdjustedSizer
Dollar risk → contracts
load-bearing
5
OMS
OrderStateMachine · BasicOrderManager · DuplicateOrderDetector
Thread-safe order lifecycle
load-bearing
6
Analytics
TradeRecorder · PerformanceCalculator · MonteCarlo · PnLAttributor
Measurement, ML dataset
built, unconsumed
7
Execution
CircuitBreaker · TrailingStopManager · ExecutionQualityTracker
Execution safety, fill quality
wired
8
Market Data
SessionManager · AVWAPCalculator · LiquidityMonitor
Context for factors
depth hardcoded
9
NT8 Adapter Ring
NT8StrategyBase (2,880 lines) · OrderAdapter · DataAdapter · LoggingAdapter
Only layer importing NinjaTrader
load-bearing

Dead code worth knowing about: RegimeManager, TrendRegimeDetector and VolatilityRegimeDetector are instantiated in Layer 2 but never called in the live signal path (DEC-20260817-04). The regime values actually used come from inline SMA20/50 arithmetic in BuildStrategyContext().

2 · The bar-to-trade pipeline

Eighteen stages between a bar closing and an order reaching the broker. The order matters: SIGNAL: is written at stage 8, before every risk gate, which is what makes a silent day diagnosable. Red rows are where trades died on 2026-08-18.

1
CME holiday guard
CmeHoliday
clear
2
Connection state
— (bar skipped)
clear
3
Kill switch
KillSwitch
off today
4
Warm-up — first realtime bar
WarmupIncomplete
17 today
5
RTH window guard
RthGuard
233 today
6
ETH telemetry branch → return
—
opt-in
7a
ORB range established
OrbRangeNotEstablished
OrbReady=True
7b
Two-bar pullback confirmation
OrbRangeNotEstablished
confirmed
7c
Direction filters · AVWAP short veto
GradeFilter
passed
7d
Confluence grade ≥ MinTradeGrade
GradeFilter
GAP-047 suspect
7e
MaxDailyTrades cap
MaxDailyTrades
not hit
8
SIGNAL: written — unconditional, before all risk gates
—
5 today
9
Historical replay catch-up block
HistoricalReplayCatchup
317 today
10
Dynamic ATR stop finalised — before sizing
—
45 ticks
11
Trailing drawdown monitor
TrailingDrawdownBreach
27 blocked
12
Portfolio risk
KillSwitch (mislabelled)
passed
13
Tier 1 per-trade risk — StopTicks × tickValue ≤ MaxTradeRisk
KillSwitch (mislabelled)
5 blocked
14
Position sizing
GradeFilter (mislabelled)
never reached
15
Circuit breaker
KillSwitch (mislabelled)
never reached
16
Runner mode resolution
—
never reached
17
SetStopLoss / SetProfitTarget → Enter…Managed
—
0 today
18
SUBMIT: + provenance row (realtime only)
—
0 today

Four rows share the label KillSwitch (stages 3, 12, 13, 15) and four share GradeFilter (7c, 7d, 14). REJECT SUMMARY aggregates on reason, so its counts are ambiguous. On 2026-08-17 a session logged KillSwitch count=647 from a genuine kill switch; on 08-18 a session logged KillSwitch count=5 from a MaxTradeRisk rejection. Splitting the taxonomy is task P0-C.

3 · Risk validation — four tiers plus the new monitor

A trade must clear every applicable tier. The annotation on Tier 1 is the most consequential correction in v7.0.

TIER 1 — BasicRiskManager ├─ Daily loss P&L ≤ −DailyLossLimit ($1,000) → HALT for the day ├─ Per-trade risk StopTicks × tickValue > MaxTradeRisk ($200) → REJECT │ ↑ NO QUANTITY TERM. Evaluated BEFORE sizing. │ ↑ NQ: caps the stop at 40 ticks. MaxStopTicks is 50. │ ↑ 2026-08-18: rejected 5 signals at $225.00 > $200.00 │ ↑ Real worst case = MaxTradeRisk × MaxContracts = $600 ├─ Position count OpenPositions ≥ MaxOpenPositions (3) → REJECT └─ 80% warning P&L ≤ −$800 → LOG only TIER 2 — AdvancedRiskManager (weekly + drawdown) ├─ Weekly loss WeeklyPnL ≤ −WeeklyLossLimit → HALT, resets Monday ├─ Trailing DD TrailingDrawdown ≥ DrawdownLimit → HALT until recovery └─ DD 80% DrawdownPct ≥ 0.8 → LOG alert TIER 3 — cross-strategy └─ Cross exposure TotalExposure > MaxCrossStrategyExposure → REJECT TIER 3.5 — portfolio heat └─ Heat % (TotalOpenRisk + NewTradeRisk) / Equity × 100 → REJECT if > MaxHeatPct (3.0%) ↑ this tier DOES include quantity — Tier 1 does not TRAILING DRAWDOWN MONITOR — account-keyed, new 2026-08-18 ├─ equity = Account.Get(AccountItem.NetLiquidation) ← not yet validated ├─ peak = max(peak, equity) ├─ lock-in if peak ≥ AccountStartingBalance + LockOffset (100) → lock ├─ reference = locked ? lockedPeak : peak ├─ floor = reference − HaltBuffer (2000) └─ GUARD: EnableTrailingDrawdown=True + AccountStartingBalance=0 → BLOCK ALL ENTRIES ↑ 2026-08-18 14:30 onward. 27 rejections. No startup assertion.

4 · Confluence scoring — designed weights vs what actually runs

Each factor calculator emits its designed weight. ConfluenceScorer's constructor pre-populates a weight dictionary with 1.0 for all ten factor types, and ResolveWeight() checks that dictionary first — so the calculators' weights are unreachable dead code. Every STATE: line in production reads x1.00.

Designed weight (from the factor calculators) Actual runtime weight (pre-populated, always 1.00)

The same ten factor scores, both ways — live data, 2026-08-18 10:10:11 ET

Composite — equal weights
0.640
Grade C · what the system logged
Composite — designed weights
0.727
Grade B · one full grade higher
Total weight
10.00 vs 5.85
Context factors carry 50% instead of 14.5%
Grade A reachability
structurally hard
Needs all ten factors ≥ 0.80 average; designed scheme reaches A on factors 1–5 alone

Live factor scores that produced those composites

#FactorScoreDesigned wtActual wtReason logged

Grade thresholds: A+ ≥ 0.90 · A ≥ 0.80 · B ≥ 0.70 · C ≥ 0.60 · D below · F at floor. The live gate configuration froze MinTradeGrade = 5 (Grade A); today's workspace runs MinTradeGrade = 4 (Grade B) — itself a drift from the frozen baseline.

5 · Runner economics — why the third contract earns nothing

Revised in rev B — the diagnosis changed. The runner is not badly tuned. Its trailing stop is switched off mid-trade. SetStopLoss() and SetTrailStop() are mutually exclusive per signal name in NinjaScript, and the auto-breakeven block calls SetStopLoss() on the runner signal — replacing a live 12-tick trail with a static stop at entry +1. In 4/4 trades the trail was already 12–16 ticks in profit when breakeven fired and was moved backwards.

AT ENTRY — correct NinjaScript SetStopLoss (_runnerSignalName, Ticks, intent.StopTicks) initial protective stop SetTrailStop(_runnerSignalName, Ticks, RunnerTrailTicks=12) ← replaces it with a LIVE 12-tick trail EnterLong/EnterShort(runnerQty, _runnerSignalName) IN OnBarUpdate — the defect (NT8StrategyBase.cs ~803) if (EnableAutoBreakeven && !_breakevenMoved && profitTicks >= 20) SetStopLoss(_runnerSignalName, Price, entry+1tick) ← DESTROYS THE TRAIL WHAT THAT DOES TO THE STOP entry ──────────────────────────────────────────────────────────────────▶ price │ ├── +12..16t where the live 12-tick trail already sat when breakeven fired │ ├── +1t where SetStopLoss moved it ← 11–15 ticks of locked profit given back │ ├── +24..28t breakeven actually fires here, not at 20 (Calculate = OnBarClose) │ └── ... trail is gone. Runner sits static until stopped near entry. THE SOURCE COMMENT FOUR LINES BELOW "Do NOT call SetTrailStop here — that resets the trail anchor..." The author correctly avoided that trap and did not notice that the SetStopLoss call above it destroys the trail outright.
TradeProfit when BE firedWhere a 12t trail satWhere the stop wentRunner grossRunner net
2026-08-07+28 t+16 t+1 t$5.00−$0.76
2026-08-10+25 t+13 t+1 t$0.00−$5.76
2026-08-16+24 t+12 t+1 t$15.00+$9.24
2026-08-17+26 t+14 t+1 t$5.00−$0.76
4 trades—55 t = $2754 t = $20$25.00+$1.96
Total net P&L
$1,035.88
4 broker-confirmed trades, after $69.12 commission
Runner share of P&L
0.19%
for 33% of contract exposure
RTH_ORB trades only
3
$758.16 · the 08-16 trade was ETH
Runner net, RTH only
−$7.28
on gate-eligible trades, it loses money
Runner net with a working trail
≈$252
conservative floor: exit at the trail's position when BE fired. It ratchets further, so this is a lower bound
Uplift on realised P&L
≈24%
$1,035.88 → ≈$1,286 · from deleting one call site

Two secondary defects in the same block. entryPrice is Position.AveragePrice — the blended 3-contract average, not the runner's own fill. On 08-16 that produced a breakeven price of 30200.08, which is not a valid NQ price (tick 0.25). And because Calculate = OnBarClose, the 20-tick trigger actually fires at 24–28 ticks.

Consequence for STAGE 2: the RUNNER-001 sweep must not run until this is fixed. An 18-combination sweep over breakeven trigger × trail distance against a runner whose trail is disabled would return a trail axis with no effect and a confident, meaningless recommendation. Fix first (task P2-0), then sweep.

6 · Parameter interaction map

Fourteen interactions between parameters that are individually reasonable. Four are actively broken; two of those are stopping trades today.

7 · Gap register

Colour is severity. GAP-045 through GAP-053 are new in v7.0. Note the numbering caution: GAP-042/043/044 mean the repository's definitions; the July audit findings that v6.4 gave those numbers are renamed HIST-41…46 to make a third collision impossible.

Blocking

Open — high

Open — medium and low

Recently closed

8 · Roadmap v7.0 — critical path

Re-sequenced around three principles: unblock before optimising, fix the measuring instrument before measuring, and treat sample rate as a first-class objective. Stage 3's duration is the whole story.

STAGE 0
Unblock
P0-A trailing drawdown · P0-A2 startup assertion · P0-B MaxTradeRisk · P0-C reject taxonomy · P0-D commit tree · P0-E re-freeze
1–2 days
optimistic 1
STAGE 1
Trustworthy instrument
P1-A factor weighting ← highest-value item in the project · P1-B risk envelope · P1-C coherence assertions · P1-D telemetry direction · P1-E gap magnitude · P1-F DaysToLoad · P1-G configdiff as a gate
1–2 weeks
optimistic 3d
STAGE 2
Runner
P2-A analyzer viability → P2-B 18-combination sweep → P2-C analyse → P2-D superseding decision · depends on P1-F
1–2 weeks
optimistic 2d
STAGE 3
Gate Run #3
≥2 weeks AND ≥20 RTH_ORB trades, single frozen account · outcome matrix decides PASS / CONDITIONAL / MARGINAL / NO EDGE / NEGATIVE / FAIL-on-risk
2–7 months
optimistic 2wk
STAGE 4
Ruling
Gate report · grade-vs-outcome correlation (never measured) · direction split · runner attribution · cost analysis · GAP-007 walk-forward
1–2 weeks
STAGE 5
Live micro
1 MNQ contract · real capital · trailing drawdown properly configured · PF > 1.8, max daily loss < $100
6–10 weeks
STAGE 6
Scale
GAP-042 account dimension (prerequisite) · scale NQ size · LondonORBNT8 · VWAPMeanReversion · overnight gap · GAP-043 bar-type evaluation
—
STAGE 7
Platform
External command channel (read side can start in Stage 3) · broker-neutral event schema · web + mobile dashboard · additional broker adapters
—
Trades in the last 6 weeks
4
≈0.7 per week
20-trade sample at that rate
≈7 months
This is the binding constraint, not the edge
To first live capital
4–10 mo
optimistic ≈11 weeks
If GAP-047 is the cause
weeks
Fixing the weighting could compress Stage 3 from months to weeks

9 · 2026-08-18 — the day in evidence

Sixteen sessions started. Five valid signals. Zero orders. Two independent blockers, both root-caused, both fixable this week.

06:50 / 07:11
Two strategy instances arm on the same account and instrument (SimSimple ORB / NQ SEP26), both on HFT Algo Bars. Both run until 13:12. single-account doctrine violated
07:11:17
Session header: DaysToLoad=3 on the primary series (configured 120) · WARNING: EnableKillSwitch=False for gate account · factor warm-up SATISFIED, 87 daily bars
09:30 – 10:00
Opening range forms: high 29,769.75, low 29,604.75 — a 165-point range
10:10:11
STATE: Regime=Bearish Direction=Sell Score=0.640 Grade=C — every factor at x1.00. STATE_CONTEXT: OrbReady=True RecommendedContracts=1. The same block reports GapDirectionAlignment="Large gap −523.25 opposes trade" on a Sell — the telemetry path's direction is stale Finding 5
10:10:24.956
SIGNAL: Sell NQ | LIVE MODE — the real intent passed the grade filter
10:10:24.956
REJECT: reason=KillSwitch detail=Risk manager rejected: Trade risk too high: $225.00
45-tick ATR stop × $5.00 = $225.00 > MaxTradeRisk $200.00. MinContracts=1 is already the floor; there is nothing to reduce. Blocker A
10:10:25 → 10:10:46
Four more SIGNAL: Sell NQ lines. All rejected. REJECT SUMMARY: reason=KillSwitch count=5
13:19 – 14:23
Five more sessions started across five different bar periods — HFT Algo, 5 Minute, 15 Minute, 30 Minute, 13 Minute. Nine distinct ConfigHash values and three distinct CodeVersion MVIDs on the day config freeze not in force
14:30:00.133
REJECT: reason=TrailingDrawdownBreach detail=EnableTrailingDrawdown=True but AccountStartingBalance is not configured
The monitor added today (DEC-20260818-17) correctly refuses to run without a floor — and its refusal blocks every entry for the rest of the session. 27 rejections. Blocker B
16:40
Last session terminates. Signals: 5 · Submissions: 0 · Fills: 0 · P&L: $0.00

What this day proves. The strategy found a textbook setup — a clean 165-point opening range, a confirmed breakout, a bearish regime, and 4.1× average breakout volume — and could not act on it, twice, for two reasons that have nothing to do with the trading hypothesis. That is the whole argument for Stage 0.

10 · The 24×5 session clock

24×5 coverage is concurrent strategy instances with disjoint session windows, not switching between strategies — settled in architecture.md on 2026-08-17. PortfolioRiskManager was already built for it. A new strategy is a new IStrategy plus a thin NinjaScript subclass; the shared base is not forked. The roadmap names four strategies. It has never had a clock. Here it is.

03:00
LondonORBNT8 — 03:00–03:30 ET opening range
Sprint 4 · named only
no design
09:30
SimpleORBNT8 — 09:30–10:00 ET opening range
under validation
the one that exists
11:00
VWAPMeanReversion — 11:00–14:00 ET
Sprint 4 · named only
no design
15:00
unassigned — closing drive / second RTH ORB
not on the roadmap
gap
18:00
unassigned — Asia-session ORB, the symmetric counterpart to London
not on the roadmap
gap
O/N
OvernightGapContinuation / OvernightGapReversion — event-driven
Sprint 4 · named only
no design

Prerequisites before any of this starts

PrerequisiteWhy
Stage 5 passedDo not multiply an unvalidated edge
GAP-042 — account dimension in PortfolioRiskManagerThe singleton is keyed only by strategyId. Fine for several strategies on one account; unsafe across accounts
GAP-055 — MaxDailyTrades persistenceA cap that resets on restart becomes per-strategy-per-restart once several instances run
A portfolio daily loss limit distinct from the sum of per-strategy limitsThree strategies at $1,000 each is a $3,000 day. The hook exists; the number has never been set
Instrument decision (MNQ vs NQ)Three strategies on NQ at MinContracts=1 is a much blunter instrument than three on MNQ

Assessment: the roadmap covers roughly two thirds of a tradeable 24×5 clock, by name only — no entry hypothesis, no session-window map before this one, no per-strategy design pass. The architecture to support it is genuinely ready and has never been collected. Correctly sequenced behind Stage 5, but the design work is a real outstanding item, not a checkbox.