Data Flow¶
Current Flow (Working)¶
Pine Script Indicators
│ Produce visual elements (labels, lines, boxes, tables)
▼
TradingView Chart (Chrome)
│ Renders indicators on chart surface
▼
Chrome DevTools Protocol (localhost:9222)
│ JavaScript evaluation in page context
▼
TradingView MCP Server (Node.js, stdio)
│ Extracts Pine graphics via internal API paths
│ Returns compact JSON to Claude
▼
Claude Code (LLM Agent)
│ Interprets signals, makes decisions
▼
MCP Tool Calls
│ chart_set_symbol, replay_trade, etc.
▼
TradingView Chart (state changes)
Pine Graphics Extraction¶
The core data pipeline reads indicator output via undocumented TradingView internals:
model().dataSources()
└─ each source._graphics._primitivesCollection
├─ dwglines.get('lines') → line.new() output
├─ dwglabels.get('labels') → label.new() output
├─ dwgboxes.get('boxes') → box.new() output
└─ dwgtablecells.get('tableCells') → table.new() output
Key API paths (discovered via live probing):
- window.TradingViewApi._activeChartWidgetWV.value() — Main chart API
- window.TradingViewApi._chartWidgetCollection — Multi-pane charts
- window.TradingViewApi._replayApi — Replay mode
- window.TradingViewApi._alertService — Alerts
Planned Flow (With Broker Layer)¶
Claude Code
│ Decides on trade setup
▼
broker_place_order (new MCP tool)
│ Direct API call to broker
▼
Tradovate / IBKR API
│ Order routed to exchange
▼
broker_get_positions (new MCP tool)
│ Read back fill confirmations
▼
FATBot Dashboard
│ Display live P&L, positions
Context Budget¶
| Operation | Bytes | Notes |
|---|---|---|
| quote_get | ~200B | Single price snapshot |
| data_get_study_values | ~500B | All visible indicator values |
| data_get_ohlcv (summary) | ~500B | Compact stats |
| data_get_ohlcv (full) | ~8KB | 100 bars |
| data_get_pine_labels | ~2-5KB | 50 labels max per study |
| data_get_pine_lines | ~1-3KB | Deduplicated levels |
| data_get_pine_tables | ~1-4KB | Formatted rows |
| capture_screenshot | ~300B | Returns file path only |
| pine_get_source | up to 200KB | Full Pine script (use sparingly) |
Target: Typical "analyze chart" workflow = 5-10KB total.