What You Are Building
A connection between Claude Code and TradingView Desktop that lets Claude read your live charts, pull indicator values, and generate Pine Script based on what it actually sees. No more copy-pasting screenshots or describing your chart in text. The MCP server handles the bridge, and this tutorial walks through the full setup.
Why This Matters
Without MCP, using Claude Code for TradingView work means describing your chart in words (“the RSI is at 65 and price just crossed above the 200 EMA”) or pasting screenshots. That works, but it is slow and error-prone. You lose context every time you switch windows.
With the TradingView MCP server running, Claude Code can:
- Read the current symbol, timeframe, and OHLC data from your chart
- Pull values from any indicator loaded on the chart
- Take chart screenshots for visual analysis
- Write and test Pine Script based on live data
- Analyze drawn objects like trendlines and support/resistance levels
The connection uses Chrome DevTools Protocol (CDP), the same debugging interface that browser developer tools use. TradingView Desktop is built on Electron (which is Chromium under the hood), so CDP gives Claude direct access to everything in the TradingView interface.
Prerequisites
- TradingView Desktop app installed (the desktop app, not the browser version)
- Claude Code installed and working
- Node.js 18+ installed
- A TradingView account (free tier works, but Pro/Premium unlocks more indicators)
If you are new to Claude Code, start with the AI trading 101 guide first.
Step 1: Install the TradingView MCP Server
The open-source tradingview-mcp project is the standard implementation. Clone it and install dependencies:
git clone https://github.com/tradesdontlie/tradingview-mcp.git ~/tradingview-mcp
cd ~/tradingview-mcp
npm install
This installs the MCP server locally. It does not modify TradingView or send data anywhere external. The server runs on your machine and communicates only between Claude Code and TradingView Desktop.
Step 2: Launch TradingView Desktop with CDP Enabled
TradingView Desktop needs to be started with the --remote-debugging-port flag so the MCP server can connect to it.
On macOS:
open -a "TradingView" --args --remote-debugging-port=9222
On Windows (PowerShell):
& "C:\Users\$env:USERNAME\AppData\Local\TradingView\TradingView.exe" --remote-debugging-port=9222
On Linux:
tradingview --remote-debugging-port=9222
Port 9222 is the standard CDP port. If something else is using it, pick another port and update the MCP config in the next step.
Tip: Create a desktop shortcut or shell alias so you do not have to type this every time. I use alias tv='open -a "TradingView" --args --remote-debugging-port=9222' in my .zshrc.
Step 3: Configure Claude Code to Use the MCP Server
Add the MCP server to your Claude Code configuration. Edit your global MCP config file:
# Global config (applies to all projects)
nano ~/.claude/.mcp.json
Add the TradingView MCP entry:
{
"mcpServers": {
"tradingview": {
"command": "node",
"args": ["/Users/YOUR_USERNAME/tradingview-mcp/src/index.js"],
"env": {
"CDP_PORT": "9222"
}
}
}
}
Replace /Users/YOUR_USERNAME/tradingview-mcp with the actual path where you cloned the repo. On Linux, this would be something like /home/YOUR_USERNAME/tradingview-mcp.
If you prefer project-level config, create a .mcp.json file in your project directory instead.
Step 4: Verify the Connection
Restart Claude Code (or start a new session), then ask it to check the TradingView connection:
Use the tv_health_check tool to verify TradingView is connected.
You should get a response like:
{
"success": true,
"cdp_connected": true,
"chart_symbol": "AAPL",
"api_available": true
}
If cdp_connected shows false, make sure TradingView Desktop is running with the --remote-debugging-port=9222 flag. If api_available is false, try restarting TradingView.
Available MCP Tools
Once connected, Claude Code gets access to these tools:
| Tool | What It Does |
|---|---|
tv_health_check | Verifies the TradingView connection is active |
tv_get_chart_data | Reads current symbol, timeframe, and OHLC data |
tv_get_indicator_values | Pulls values from loaded indicators (RSI, EMA, MACD, etc.) |
tv_screenshot | Takes a screenshot of the current chart |
tv_get_drawing_objects | Reads trendlines, horizontal lines, and other drawn objects |
tv_execute_pine | Runs Pine Script on the chart |
tv_change_symbol | Switches the chart to a different symbol |
tv_change_timeframe | Changes the chart timeframe |
Practical Workflow: Chart Analysis
Here is how I actually use this setup day to day. Open TradingView with your chart loaded, then in Claude Code:
Look at my current chart. What symbol am I on, what timeframe,
and what do the RSI and MACD look like? Any divergences?
Claude reads the chart data and indicator values directly. No screenshots, no describing what you see. If you have support/resistance lines drawn, Claude can read those too and factor them into the analysis.
Practical Workflow: Pine Script from Live Data
This is where the setup really pays off. Instead of writing a generic Pine Script prompt, you can say:
I'm looking at BTCUSD on the 4H chart. Write a Pine Script indicator
that highlights the zones where RSI went below 30 while price was
above the 200 EMA on this timeframe. Use the actual current EMA value
as a reference point in your comments.
Claude reads the live chart data, checks the current EMA value, and writes Pine Script that is grounded in what is actually happening on the chart.
Practical Workflow: Morning Brief
One workflow that works well for daily trading: create a prompt that pulls data from multiple symbols and generates a morning brief.
Check these symbols on the daily timeframe: SPY, QQQ, BTCUSD, ETHUSD.
For each one, get the RSI, 50 EMA, and 200 EMA values.
Flag anything with RSI below 35 or above 70, or where price is
within 1% of either EMA. Format as a table.
Claude switches between symbols, reads the data, and gives you a structured overview. It takes about 30 seconds instead of clicking through four charts manually.
Troubleshooting
“CDP connection failed”: TradingView Desktop is not running with the debug port flag. Close it completely and relaunch with --remote-debugging-port=9222.
“Chart data unavailable”: This usually means TradingView is still loading. Wait a few seconds after the app opens before running commands. Also check that you have a chart open (not the screener or ideas page).
MCP server not showing in Claude Code: Make sure the path in .mcp.json is absolute (not relative) and points to the correct index.js file. Run node ~/tradingview-mcp/src/index.js manually to check for errors.
TradingView Desktop v2.14+ issues: Some users report the CDP port not opening on newer versions. The Jackson fork of the MCP server includes a fix for this. Check the repo’s issues page if you are on v2.14 or later.
Limitations
Be upfront about what this setup cannot do:
- No live order execution from Claude Code. The MCP server reads chart data. It does not connect to a broker. For automated trading, you still need a separate bot (Binance setup, IBKR setup).
- TradingView Desktop only. The browser version of TradingView does not expose a CDP port in the same way. You need the desktop app.
- Indicator values depend on what is loaded. Claude can only read indicators that are already on your chart. If you want RSI values, the RSI indicator must be visible.
- Free TradingView tier has limits. You can only load 3 indicators at once on the free plan. Pro or Premium gives you more.
What to Build Next
With the TradingView MCP connection working, you can:
- Build a multi-timeframe trend dashboard using live chart data as input
- Create a daily analysis workflow that checks multiple symbols
- Use Claude Code to iterate on Pine Script with live feedback instead of guessing
- Combine chart analysis with a news trading bot for a more complete picture
The MCP connection turns Claude Code from a code generator into something closer to a trading copilot. It still cannot make trading decisions for you, and it should not. But it removes the friction of manually bridging your AI tools and your charting platform.