docs: add chart diagnostics and dashboard training

This commit is contained in:
2026-08-16 18:03:49 -04:00
parent 7f82a92d8d
commit 8ca000a166
2 changed files with 327 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
# Chart Diagnostics Training
**Created:** 2026-08-16
**Scope:** NinjaTrader chart drawings emitted by `SimpleORBNT8` when `EnableChartDiagnostics=True`
## What This Is
The chart diagnostics overlay is a NinjaTrader chart-only visual aid. It is separate from the browser dashboard under `tools/dashboard/`.
The overlay is made from NinjaScript `Draw.*` objects and fixed text labels. It does not add indicators through `AddChartIndicator`, and it does not create a separate panel.
## How To Turn It On
1. Open the chart running `Simple ORB NT8`.
2. Open the strategy settings.
3. Find the `Diagnostics` section.
4. Set `Enable Chart Diagnostics=True`.
5. Apply or reload the strategy.
Default state: `EnableChartDiagnostics=False`.
## Why The Top Left Can Be Hard To Read
The top-left chart area can contain multiple things at once:
- NinjaTrader's built-in strategy label, for example `Simple ORB NT8(...)`.
- `RUNNER: <mode>` from the SDK diagnostics.
- `REGIME: BULLISH` or `REGIME: BEARISH` when regime data is available.
- `DAILY TRADES: <count>` once the strategy records a daily trade count.
- `TRADE TAKEN (TestMode)` if `TestMode=True` and a test trade has been marked.
These are fixed-position NT8 labels, so they can overlap. If the text is unreadable, that is a chart-layout limitation of the current diagnostics, not proof that the strategy is malfunctioning.
## What Each Visual Means
| Visual | Location | Meaning | When It Appears |
|---|---|---|---|
| `SESSION: RTH` / `SESSION: ETH` | Top right | Current session classification used by the strategy context | When session context exists |
| `RUNNER: <mode>` | Top left | Current runner activation mode, such as `Auto` | When runner is enabled |
| `REGIME: BULLISH` / `REGIME: BEARISH` | Top left | AVWAP slope regime from strategy parameters | When `avwap_slope` is available |
| `TEST MODE ACTIVE` | Center | Strategy is in test mode | Only when `TestMode=True` |
| `Prov: settings_<name>_<date>` | Bottom right | Reminder that settings/provenance files are being produced | When chart diagnostics run |
| Blue ORB box | Around latest bar range | Opening range high/low diagnostic box | After opening range is ready |
| Green dashed line | Chart price level | Long breakout trigger | After opening range is ready |
| Red dashed line | Chart price level | Short breakout trigger | After opening range is ready |
| Breakout arrow | Near ORB high/low | Breakout bar seen by strategy state | After breakout bar is detected |
| `ORB: <ticks> ticks | Mult: <n>` | Bottom left | Opening range size in ticks and standard-deviation multiplier | After opening range is ready |
| `BREAKOUT: LONG` / `BREAKOUT: SHORT` | Bottom left | Pending breakout direction | After breakout bar is detected |
| Cyan dashed line | Price level | Dynamic ATR stop diagnostic | When dynamic stop is enabled and ATR is warmed up |
| Lime dotted line | Price level | Breakeven diagnostic line | After breakeven has moved |
| `DAILY TRADES: <count>` | Top left | Strategy daily trade count | After daily trade count is greater than zero |
## Reading The Screenshot Pattern
If you see text like this in the top left:
```text
Simple ORB NT8(...)
RUNNER: AUTO
DAILY TRADES: 1
```
Interpret it as:
- The built-in NT8 strategy label is drawing first and may be long because it includes many strategy parameter values.
- `RUNNER: AUTO` means the runner subsystem is enabled and set to automatic activation.
- `DAILY TRADES: 1` means the strategy state has counted one accepted daily trade for the session.
The labels overlapping does not change order behavior. For audit-quality evidence, use the session log and dashboard; use the chart overlay only as a quick visual aid.
## Recommended Operator Use
For normal gate operation:
1. Keep `EnableChartDiagnostics=False` unless you are intentionally inspecting chart state.
2. Use session logs and preflight output as the authoritative record.
3. Use the browser dashboard for readable live/session summaries.
4. Turn chart diagnostics on only when you need visual confirmation of ORB/triggers/breakeven state.
For training or debugging:
1. Turn `EnableChartDiagnostics=True`.
2. Expand the chart horizontally so price bars and labels have room.
3. If top-left text is unreadable, focus on the individual colors and fixed positions in the table above.
4. Cross-check with the session file log under `C:\Users\billy\Documents\NinjaTrader 8\log\nt8-sdk`.
## Important Limits
- The chart diagnostics are not the dashboard.
- The chart diagnostics do not show every risk decision.
- The chart diagnostics are not the source of truth for Gate Run evidence.
- A missing ORB box before the ORB window completes is normal.
- A missing breakout arrow before a breakout is detected is normal.
- Overlap with the NinjaTrader strategy label is currently expected.
## Source References
- `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` — base diagnostics: session, runner, regime, test mode, ATR stop, breakeven, provenance label.
- `src/NT8.Adapters/Strategies/SimpleORBNT8.cs` — ORB diagnostics: ORB box, trigger lines, breakout arrow, ORB range text, breakout direction, daily trade count.

View File

@@ -0,0 +1,229 @@
# Dashboard Training
**Created:** 2026-08-16
**Scope:** Standalone read-only browser dashboard under `tools/dashboard/`
## What This Is
The dashboard is a separate browser UI. It is not a NinjaTrader chart overlay and it does not draw on the NT8 chart.
It reads existing files from disk:
- `session_*.log`
- `trades_*.jsonl`
- `provenance_*.json`
- `settings_*.txt`
Default log directory:
```text
C:\Users\billy\Documents\NinjaTrader 8\log\nt8-sdk
```
## Safety Model
- Read-only UI.
- No order controls.
- No pause, flatten, kill switch, or broker actions.
- No NinjaTrader assembly references.
- No writes to NinjaTrader directories.
- Live server binds only to `127.0.0.1`.
- Only `GET`, `HEAD`, and `OPTIONS` are allowed.
- Local runtime state is written to `tools/dashboard/dashboard_state.json` when the live server is used.
## Launch Modes
### Live Mode
Use this when you want the browser to update from the newest NT8 log files while NT8 is running.
From `C:\dev\nt8-sdk`:
```powershell
Copy-Item .\tools\dashboard\config.example.json .\tools\dashboard\config.json
python .\tools\dashboard\server.py --config .\tools\dashboard\config.json
```
Open:
```text
http://127.0.0.1:8765/
```
The browser polls `/api/state` automatically.
### Static Localhost Mode
Use this when you want to view the dashboard UI without running the live parser server.
```powershell
python -m http.server 8765 --bind 127.0.0.1 --directory tools/dashboard
```
Open:
```text
http://127.0.0.1:8765/
```
Then load a generated `triage.json` manually.
### Direct File Mode
Use this for the simplest offline viewing path.
```powershell
Start-Process .\tools\dashboard\index.html
```
Then load a generated `triage.json` manually.
## Generating Offline Input
From `C:\dev\nt8-sdk`:
```powershell
python tools\logtriage\logtriage.py --json | Out-File -Encoding utf8 triage.json
```
Then open the dashboard and select `triage.json`.
PowerShell 5.1 writes UTF-16LE by default when using `>`. Use `Out-File -Encoding utf8` so the browser can read the JSON.
## Main Views
### Gate Progress
Shows the current gate evidence summary:
- Trades banked toward the 20-trade target.
- Elapsed session days.
- Traded-session streak.
- Diagnostic count.
Use this to answer: "Are we accumulating a valid gate run?"
### Daily Timeline
Shows one row per session/day.
Typical classifications:
- Traded day: session has signal/order/fill evidence.
- Silent day: session start exists but no `SIGNAL`, `SUBMIT`, or `FILL` lines.
- Config violation: settings or session data violates gate expectations.
- Parallel instance: more than one account, bar type, or config state appears on the same day.
Use this to answer: "Which days are valid evidence, and which days are contaminated?"
### Trade Detail
Shows per-trade records parsed from `trades_*.jsonl`.
Important columns include:
- Timestamp.
- Side.
- Quantity.
- Grade.
- Score.
- Runner mode.
- Session tag.
- Scaler and runner PnL if available.
Use this to answer: "What did the strategy actually trade, and how did the runner/scaler perform?"
### Provenance Health
Shows whether trade records contain useful provenance or sentinel/default values.
Watch for fields like:
- `confluence_grade=Unknown`
- `confluence_score=0.0`
- `risk_mode=Unknown`
Use this to answer: "Can these trade records be trusted as gate evidence?"
### Config Integrity
Shows `ConfigHash` and `CodeVersion` over time.
Use this to answer: "Did the strategy config or deployed code change during the run?"
## Live Notifications
Notifications are optional and use Apprise.
Install support:
```powershell
python -m pip install -r .\tools\dashboard\requirements.txt
```
Edit local `tools/dashboard/config.json` and set:
```json
"notifications": {
"enabled": true,
"targets": [
"discord://webhook_id/webhook_token",
"ntfy://ntfy.sh/your-topic"
]
}
```
Do not commit `tools/dashboard/config.json`; it is local operator configuration.
Notification events:
- `SUBMIT`
- `FILL`
- `BREAKEVEN`
- `CONNECTION LOST`
- `CONNECTION RESTORED`
- `PNL_UPDATE` crossing configured daily PnL milestones
## How This Relates To The Chart Overlay
The chart overlay answers: "What is the strategy drawing on this chart right now?"
The dashboard answers: "What did the logs and trade records say across sessions?"
Use them together:
1. Use the chart diagnostics for immediate visual state such as ORB lines or breakout arrows.
2. Use the dashboard for readable session history, trades, config drift, provenance health, and gate evidence.
3. Use raw session logs for the authoritative audit record.
## GAP-034 Cross-Check Use
During the GAP-034 diagnostic session, keep the NT8 Output window open and compare it to session-file lines that start with:
```text
REJECT: reason=
REJECT SUMMARY: reason=
```
The dashboard can help locate the newest session log and highlight silent days, but the required cross-check is Output window text versus the session file log.
## Troubleshooting
If the dashboard page opens but shows no live data:
- Confirm `python .\tools\dashboard\server.py --config .\tools\dashboard\config.json` is running.
- Confirm the URL is `http://127.0.0.1:8765/`.
- Confirm `log_dir` in `config.json` points to `C:\Users\billy\Documents\NinjaTrader 8\log\nt8-sdk`.
- Confirm NT8 has produced `session_*.log`, `trades_*.jsonl`, or `settings_*.txt` files.
If notifications do not fire:
- Confirm Apprise is installed.
- Confirm `notifications.enabled=true`.
- Confirm the target URL is correct.
- Watch the server console for notification errors.
If the dashboard seems stale:
- Refresh the browser.
- Restart `server.py`.
- Delete `tools/dashboard/dashboard_state.json` only if you intentionally want notification dedup state reset. The server avoids replaying already-existing historical notifications on restart.