Trading Automation

TradingView Pine Script MCP: Write, Edit and Run Strategies with Claude AI

The TradingView MCP is an open-source Model Context Protocol server that gives any AI coding assistant — Claude AI, Cursor, or Google Antigravity direct programmatic control over TradingView. Write Pine Script, compile strategies, read live OHLCV data, manage alerts, capture chart screenshots, run batch analysis across symbols, and automate your entire trading workflow. All from a single chat prompt.

This guide walks through the full setup and explains exactly what each AI client can do with it and how to choose the right one for your workflow.

What You Will Learn
What the TradingView MCP is and how it works under the hood via Chrome DevTools Protocol
How to install and configure it on Windows, macOS, and Linux in under 5 minutes
How to connect it to Claude AI, Cursor IDE, and Google Antigravity
All 81 tools it exposes — from Pine Script compilation to multi-symbol batch analysis
How to run a full morning brief: scan your watchlist, read indicators, get session bias

TradingView MCP connecting Claude AI to TradingView for automated chart control and Pine Script writing
TradingView MCP bridges your AI assistant directly to TradingView — no manual copy-paste, no switching windows

What Is the TradingView MCP?

The TradingView MCP (by LewisWJackson on GitHub) is a Node.js server that implements the Model Context Protocol the open standard that lets AI assistants call external tools. It connects to TradingView via the Chrome DevTools Protocol (CDP) on port 9222, giving your AI assistant the ability to read and write anything inside TradingView’s interface programmatically.

The architecture is straightforward:

Your AI Assistant (Claude / Cursor / Antigravity)
         ↕  MCP protocol (stdio)
TradingView MCP Server (Node.js)
         ↕  Chrome DevTools Protocol (CDP · port 9222)
TradingView Desktop (running locally)

Nothing goes to the cloud. All data processing is local. TradingView market data never leaves your machine.

Prerequisites

  • TradingView Desktop installed on Windows, macOS, or Linux
  • Node.js 18 or higher available at nodejs.org
  • Git — to clone the repository
  • One of: Claude Code, Cursor IDE, or Google Antigravity

Installation: 3 Steps

Three-step installation diagram for TradingView MCP showing clone install launch and connect steps
Three steps from zero to a fully connected AI-controlled TradingView

Step 1: Clone and Install

git clone https://github.com/LewisWJackson/tradingview-mcp-jackson.git
cd tradingview-mcp-jackson
npm install
cp rules.example.json rules.json

Step 2: Launch TradingView with Debug Port

PlatformCommand
Windowsscripts\launch_tv_debug.bat
macOS./scripts/launch_tv_debug_mac.sh
Linux./scripts/launch_tv_debug_linux.sh
Any (via MCP tool)Ask Claude: “Launch TradingView”

Or manually on Windows with PowerShell:

Start-Process "$env:LOCALAPPDATA\TradingView\TradingView.exe" "--remote-debugging-port=9222"

Step 3: Register with Your AI Client

Add the MCP server to your AI client config. The JSON format is identical for Claude Code, Cursor, and Antigravity — only the config file location differs.

{
  "mcpServers": {
    "tradingview": {
      "command": "node",
      "args": ["/path/to/tradingview-mcp-jackson/src/server.js"]
    }
  }
}

What Can It Do? All 81 Tools

Visual overview of TradingView MCP 81 tools organized by category including Pine Script alerts chart control and data reading
81 tools across 14 categories — from Pine Script development to multi-symbol batch analysis
CategoryKey ToolsWhat It Does
Pine Scriptpine_inject, pine_compile, pine_saveWrite, compile, and save Pine Script strategies without opening the editor
Chart Controltv_symbol, tv_timeframe, tv_styleChange symbol, timeframe, and chart type programmatically
Data Readingtv_ohlcv, tv_study_value, tv_drawingsRead live OHLCV bars, indicator values, and all chart drawings
Alertstv_alert_create, tv_alert_list, tv_alert_deleteCreate, list, and delete price alerts programmatically
Capturetv_screenshotTake full chart or region screenshots on demand
Morning Briefmorning_brief, session_saveScan watchlist, apply your rules, return structured session bias

Want to go deeper on using Claude to write Pine Script? Read: Claude AI Pine Script: Write V6 Strategies That Actually Compile.

Morning Brief — The Flagship Feature

Set up your rules.json with your watchlist and bias criteria, then ask your AI assistant: “Run morning brief.” It will cycle through every symbol, read all indicator values, apply your rules, and return a structured session bias report — saved to ~/.tradingview-mcp/sessions/YYYY-MM-DD.json for comparison.

npm link          # install tv CLI globally (one-time)
tv brief          # run morning brief
tv session get    # view today's session
tv quote          # current price
tv symbol BTCUSD  # switch symbol

Using the MCP with Claude AI, Cursor & Antigravity

Comparison diagram of Claude AI Cursor IDE and Google Antigravity connecting to TradingView through the MCP server
Claude AI, Cursor, and Google Antigravity all connect through the same MCP config

Option 1: Claude AI (Recommended)

Claude Code is the primary client this MCP was designed for. It has best-in-class MCP integration, handles multi-step agentic tasks natively, and the repo includes a CLAUDE.md decision tree that helps Claude pick the right tool for every situation automatically.

Config file: ~/.claude/.mcp.json

{
  "mcpServers": {
    "tradingview": {
      "command": "node",
      "args": ["/Users/YOUR_USERNAME/tradingview-mcp-jackson/src/server.js"]
    }
  }
}

Once connected, ask Claude things like:

  • “Write a Bollinger Band + EMA strategy and compile it on BTCUSD”
  • “Take a screenshot of the current chart”
  • “Create an alert for when price crosses above the upper Bollinger Band with PickMyTrade webhook”
  • “Run morning brief on my watchlist”
  • “Read the last 50 OHLCV bars and tell me if momentum is bullish”

Claude handles multi-step workflows automatically — it will compile, add to chart, and create the alert in a single conversation turn. Here’s exactly how it works:

Step 1: Claude Writes the Pine Script Strategy

You describe what you want in plain English. For example:

“Write a Pine Script v6 strategy that uses a 20-period Bollinger Band and a 50-period EMA. Go long when price closes above the upper band and the EMA is trending up. Add a PickMyTrade alert on every signal.”

Claude generates the complete, ready-to-compile script and injects it directly into TradingView:

//@version=6
strategy("BB + EMA Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)

// Inputs
bbLength  = input.int(20,  "BB Length")
bbMult    = input.float(2.0, "BB Multiplier")
emaLength = input.int(50,  "EMA Length")

// Indicators
[bbUpper, bbBasis, bbLower] = ta.bb(close, bbLength, bbMult)
emaLine = ta.ema(close, emaLength)

// Conditions
emaUp    = emaLine > emaLine[1]
longCond = close > bbUpper and emaUp

// Entry / Exit
if longCond
    strategy.entry("Long", strategy.long)

if ta.crossunder(close, bbBasis)
    strategy.close("Long")

// PickMyTrade Alert
alertcondition(longCond, title="BB+EMA Long",
  message='{"symbol":"{{ticker}}","action":"buy","qty":1,"source":"TradingView"}')

plot(bbUpper, color=color.blue,   title="BB Upper")
plot(bbLower, color=color.blue,   title="BB Lower")
plot(emaLine,  color=color.orange, title="EMA 50")

Step 2: Claude Edits the Strategy On Request

Want to tweak it? Just tell Claude what to change — no manual code editing needed:

Your RequestWhat Claude Changes
“Change the EMA to 21 periods”Updates emaLength default to 21
“Add a 1% stop loss”Adds strategy.exit() with stop offset
“Switch to BTCUSDT alerts”Updates alert message symbol field
“Make it work on 15-min charts”Adjusts logic for lower timeframe noise
“Add a short entry on lower band break”Adds short condition + strategy.entry(“Short”)

Claude injects the updated code directly into TradingView, compiles it, and confirms the changes — all without you touching a line of code.

Step 3: Claude Creates the PickMyTrade Alert

Once the strategy is on the chart, Claude uses the tv_alert_create tool to set up the alert with the correct PickMyTrade webhook JSON pre-filled — no copying and pasting required. Your automated trade signal is live in seconds.

Option 2: Cursor IDE

Cursor fully supports MCP servers. Navigate to Settings → Cursor Settings → Tools & MCP → Add New MCP Server, or manually edit ~/.cursor/mcp.json with the same JSON structure shown above. Cursor supports up to 40 active MCP tools simultaneously — with 81 tools in this MCP, consider disabling other MCPs while working with TradingView.

Best for: Developers who want to build Pine Script libraries and control TradingView from within a full code editor environment.

Option 3: Google Antigravity

Google Antigravity is Google’s agent-first IDE released in January 2026 and available free for individuals. Full MCP support was added in early 2026 using the same configuration format as Claude and Cursor. The default model is Gemini 3 Pro, with optional Claude Sonnet and OpenAI support available. Its agent-first design makes multi-step MCP workflows run especially smoothly.

Config: Settings → MCP Servers → Add Server (same JSON structure as above)

Best for: Users already in the Google ecosystem who want a free agentic IDE with generous rate limits.

Quick Comparison

FeatureClaude CodeCursorAntigravity
MCP supportNativeFullFull (since 2026)
Agentic multi-stepBest-in-classGoodStrong
CLAUDE.md decision treeIncludedNot availableNot available
CostPaid (usage-based)Paid subscriptionFree for individuals
Best modelClaude Sonnet / OpusClaude / GPT-4oGemini 3 Pro

Real Workflow Example: Pine Script + Alert in One Prompt

“Write a Bollinger Band + 50 EMA strategy in Pine Script v6, compile it on the current chart, then create a TradingView alert with the PickMyTrade webhook JSON.”

Claude (using the TradingView MCP) automatically chains the tool calls: pine_injectpine_compiletv_alert_create → done. The full pipeline runs in under 60 seconds with no manual steps — as demonstrated in the example above.

Connecting Alerts to Live Trades with PickMyTrade

Once your strategy is on the chart and alerts are configured, PickMyTrade handles the execution layer. The MCP includes the PickMyTrade webhook JSON in every alert it creates:

{
  "strategy_name": "BB+EMA",
  "symbol": "{{ticker}}",
  "date": "{{timenow}}",
  "data": "{{strategy.market_position}}",
  "quantity": 10,
  "price": "{{close}}",
  "platform": "BINANCE",
  "order_type": "MKT",
  "market_type": "future",
  "token": "YOUR_TOKEN",
  "reverse_order_close": true,
  "multiple_accounts": [{"connection_name": "BINANCE1"}]
}

When TradingView fires the alert, PickMyTrade reads the data field long, short, or flat and executes the corresponding market order on Binance, Bybit, or any connected exchange in real time.

You May Also Like

Frequently Asked Questions

Does this work with TradingView browser or only Desktop?

Designed for TradingView Desktop. The browser version also works if you launch Chrome with --remote-debugging-port=9222 and navigate to TradingView, but Desktop is more reliable for production use.

Do I need a paid TradingView plan?

TradingView Desktop is free. Webhook alerts require TradingView Pro or higher. Chart control, Pine Script compilation, screenshots, and data reading work on any plan.

Can I use this with Windsurf or VS Code?

Yes. Any MCP-compatible client works — Windsurf, VS Code with the MCP extension, JetBrains. All use the same mcp.json configuration format.

Is my trading data sent anywhere?

No. The TradingView MCP runs entirely locally. Chart data, indicator values, and Pine Script code never leave your machine. Only the AI assistant conversation itself goes to the respective cloud provider (Anthropic, OpenAI, or Google).

What is the rules.json file for?

It defines your watchlist, default timeframe, and the criteria your AI uses to determine session bias — for example, “bullish if RSI is above 50 and price is above the 200 EMA.” During a morning brief, Claude applies these rules to each symbol and returns a structured bias table. Copy rules.example.json to rules.json and customize it for your strategy.

Ready to route your TradingView signals into live trade execution? PickMyTrade connects TradingView alerts directly to Binance, Bybit, and 10+ exchanges — market orders, limit orders, and full position management, automatically. Trading Tradovate futures? Use pickmytrade.trade.

Bhavishya Goyal is the lead developer and content strategist at PickMyTrade, specializing in automated trading systems, TradingView automation, and prop firm trading solutions. With deep expertise in algorithmic trading and trade copier technology, Bhavishya writes about trading automation strategies, broker integrations, and Pine Script development.

Leave a Reply

Your email address will not be published. Required fields are marked *