TradingView MCP
🇹🇭 ภาษาไทย
tradingview-mcp — MCP server ที่ connect Claude Code กับ TradingView Desktop app ผ่าน Chrome DevTools Protocol (CDP) สำหรับ AI-assisted chart analysis, Pine Script development, และ workflow automation
- ผู้สร้าง: tradesdontlie (github.com/tradesdontlie/tradingview-mcp)
- License: MIT | ไม่ได้ affiliated กับ TradingView Inc. หรือ Anthropic
- ต้องการ: TradingView subscription ที่ถูกต้อง
ข้อมูลทั้งหมดประมวลผล locally เท่านั้น ไม่ส่งออกนอกเครื่อง
สถาปัตยกรรม
Claude Code ←→ MCP Server (stdio) ←→ CDP (port 9222) ←→ TradingView Desktop (Electron)
78 MCP tools + CLI tv command (30 commands, 66 subcommands)
Setup
git clone https://github.com/tradesdontlie/tradingview-mcp.git
cd tradingview-mcp && npm install
# Mac: launch TradingView with CDP
./scripts/launch_tv_debug_mac.shเพิ่มใน ~/.claude/.mcp.json:
{ "mcpServers": { "tradingview": { "command": "node", "args": ["/path/to/server.js"] } } }Tool Categories (78 tools)
| Category | จำนวน | ตัวอย่าง |
|---|---|---|
| Chart Reading | 4 | chart_get_state, quote_get, data_get_study_values |
| Pine Drawings | 4 | data_get_pine_lines, data_get_pine_labels, data_get_pine_tables |
| Chart Control | 10 | chart_set_symbol, chart_set_timeframe, chart_manage_indicator |
| Pine Script Dev | 10 | pine_set_source → pine_smart_compile → pine_get_errors → pine_save |
| Multi-Pane | 4 | pane_set_layout (s/2h/2v/2x2/4/6/8), pane_set_symbol |
| Replay Mode | 6 | replay_start → replay_step → replay_trade → replay_stop |
| Drawing/Alerts | 6 | draw_shape, alert_create |
| Streaming | 6 | tv stream quote/bars/values/lines/tables/all |
| Utilities | 8+ | capture_screenshot, batch_run, tv_health_check |
Natural Language → Tool Decision
| พูดว่า… | Claude ใช้… |
|---|---|
| ”What’s on my chart?” | chart_get_state → data_get_study_values → quote_get |
| ”Switch to AAPL daily” | chart_set_symbol → chart_set_timeframe |
| ”Write a Pine Script for…” | pine_set_source → pine_smart_compile → pine_get_errors |
| ”Set up a 4-chart grid” | pane_set_layout → pane_set_symbol |
| ”Take a screenshot” | capture_screenshot |
Related
- ML4T Platform — comprehensive ML for trading education
- ML4T Book 2nd Edition — textbook 858 หน้า
- Algorithmic Trading — domain concept
- OpenClaw — personal AI assistant ที่ใช้ MCP pattern เหมือนกัน
🇬🇧 English
tradingview-mcp — an MCP server that connects Claude Code to your TradingView Desktop app via Chrome DevTools Protocol (CDP) for AI-assisted chart analysis, Pine Script development, and workflow automation.
- Author: tradesdontlie (github.com/tradesdontlie/tradingview-mcp)
- License: MIT | Not affiliated with TradingView Inc. or Anthropic
- Requires: A valid TradingView subscription
All data processing is local. No TradingView data is transmitted externally.
Architecture
Claude Code ←→ MCP Server (stdio) ←→ CDP (port 9222) ←→ TradingView Desktop (Electron)
78 MCP tools exposed over stdio + a tv CLI command (30 commands, 66 subcommands). The only dependencies are @modelcontextprotocol/sdk and chrome-remote-interface.
Setup
git clone https://github.com/tradesdontlie/tradingview-mcp.git
cd tradingview-mcp && npm install
./scripts/launch_tv_debug_mac.sh # Mac; see scripts/ for Windows/LinuxAdd to ~/.claude/.mcp.json:
{ "mcpServers": { "tradingview": { "command": "node", "args": ["/path/to/server.js"] } } }Verify: Ask Claude to run tv_health_check.
Tool Reference (78 Tools)
Chart Reading (4 tools)
| Tool | Use | Output |
|---|---|---|
chart_get_state | First call — get symbol, timeframe, all indicator names + IDs | ~500B |
data_get_study_values | Read RSI, MACD, BB, EMA values from all indicators | ~500B |
quote_get | Latest price, OHLC, volume | ~200B |
data_get_ohlcv | Price bars — use summary: true for compact output | 500B / 8KB |
Pine Drawings — Custom Indicator Data (4 tools)
| Tool | Use |
|---|---|
data_get_pine_lines | Horizontal price levels (support/resistance, session levels) |
data_get_pine_labels | Text annotations with prices (“PDH 24550”, “Bias Long”) |
data_get_pine_tables | Data tables (session stats, analytics dashboards) |
data_get_pine_boxes | Price zones/ranges as {high, low} pairs |
Always use
study_filter: "Indicator Name"to target a specific indicator.
Pine Script Development (10 tools — in order)
pine_set_source → pine_smart_compile → pine_get_errors → pine_get_console → pine_save
Also: pine_get_source, pine_new, pine_open, pine_list_scripts, pine_analyze, pine_check
Multi-Pane Layouts: pane_list · pane_set_layout (s/2h/2v/2x2/4/6/8) · pane_focus · pane_set_symbol
Replay Mode: replay_start → replay_step → replay_autoplay → replay_trade → replay_status → replay_stop
Drawing & Alerts: draw_shape (horizontal_line/trend_line/rectangle/text) · draw_list · draw_remove_one · draw_clear · alert_create · alert_list · alert_delete
Streaming:
tv stream quote # price tick monitoring
tv stream bars # bar-by-bar updates
tv stream values # indicator value monitoring
tv stream all # all panes simultaneouslyNatural Language Decision Tree
| You say… | Claude uses… |
|---|---|
| ”What’s on my chart?” | chart_get_state → data_get_study_values → quote_get |
| ”Give me a full analysis” | quote_get → study values → lines → labels → tables → ohlcv → screenshot |
| ”Switch to AAPL daily” | chart_set_symbol → chart_set_timeframe |
| ”Write a Pine Script for…” | pine_set_source → pine_smart_compile → pine_get_errors |
| ”Start replay at March 1st” | replay_start → replay_step → replay_trade |
| ”Set up a 4-chart grid” | pane_set_layout → pane_set_symbol (×4) |
| “Draw a level at 24500” | draw_shape (horizontal_line) |
Context Management
Tools return compact output by default. A typical “analyze my chart” workflow uses ~5-10KB instead of ~80KB.
| Feature | How it saves context |
|---|---|
| Pine lines | Deduplicated price levels only |
| Pine labels | Capped at 50 per study, text+price only |
| OHLCV summary mode | Stats + last 5 bars instead of all bars |
study_filter | Target one indicator instead of scanning all |
verbose: true | Pass on any pine tool to get raw data when needed |
Research Context
This is an open research project investigating how LLM agents interact with professional trading interfaces: MCP as a bridge between LLMs and stateful desktop financial applications, latency/reliability constraints in live chart environments, and failure modes of LLM agents in real-time data settings. It is not a trading bot — it is an interface layer.