A TradingView bot is the fastest way to turn a backtested strategy into a live, fully automated trading system. Instead of manually watching alerts, copying numbers, and typing orders into MetaTrader — a TradingView bot does all of it for you, in under 50 milliseconds, 24 hours a day.
In this guide, you'll learn exactly how to build a TradingView automated trading bot from scratch. We'll cover the architecture, the Pine Script code, the webhook configuration, and the tool that connects everything to MT5 — TradingView Copier Pro.
TL;DR: A TradingView bot = Pine Script strategy + webhook alert + TradingView Copier Pro + MT5. Total setup time: under 10 minutes. No coding beyond basic Pine Script required.
What Is a TradingView Bot?
A TradingView bot is an automated system that uses TradingView alerts to trigger real trades on a broker platform like MetaTrader 5. Here's the key insight: TradingView already has everything you need for strategy development and signal generation — charts, indicators, backtesting, and alerts. The missing piece is execution.
That's what a TradingView bot solves. It bridges the gap between "TradingView says BUY" and "your broker actually executes the buy order."
There are three types of TradingView bots:
- Webhook-based bots — TradingView sends a webhook when an alert fires. A local or cloud server receives it and executes the trade. This is the fastest and most reliable approach.
- API polling bots — A script periodically checks TradingView for new alerts. Slower and less reliable.
- Browser automation bots — A script clicks buttons in TradingView's UI. Fragile and not recommended.
This guide focuses on webhook-based bots — specifically using TradingView Copier Pro, which handles the entire webhook → MT5 pipeline for you.
How a TradingView Bot Works (Architecture)
Here's the complete data flow of a TradingView webhook bot:
- Pine Script strategy generates a BUY or SELL signal on TradingView
- TradingView alert fires and sends a webhook HTTP POST to your URL
- TradingView Copier Pro (running on your PC/VPS) receives the webhook via Cloudflare tunnel
- The app parses the signal — action (BUY/SELL/CLOSE), symbol, lot size, SL/TP
- Expert Advisor on MT5 receives the command via local socket and executes the trade
- Trade appears in MT5 within 15–50ms of the original alert
The entire round trip — from Pine Script signal to MT5 order fill — takes under 50 milliseconds. That's faster than you can blink.
What You Need to Get Started
Building a TradingView bot requires four components:
- TradingView account — Essential plan or higher (webhooks require a paid plan)
- Pine Script strategy — Any strategy that generates BUY/SELL signals
- TradingView Copier Pro — The webhook receiver + MT5 bridge
- MetaTrader 5 — Any broker's MT5 terminal (demo or live)
Optional but recommended:
- Windows VPS — For 24/7 operation (your PC doesn't need to stay on)
- Multiple MT5 accounts — Copy trades to several brokers simultaneously
Step 1: Create Your Pine Script Strategy
Every TradingView bot starts with a Pine Script strategy. Here's a simple moving average crossover example optimized for webhook alerts:
//@version=5
strategy("MA Crossover Bot", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=2)
fastLen = input.int(9, "Fast MA Length")
slowLen = input.int(21, "Slow MA Length")
fastMA = ta.sma(close, fastLen)
slowMA = ta.sma(close, slowLen)
longCondition = ta.crossover(fastMA, slowMA)
shortCondition = ta.crossunder(fastMA, slowMA)
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
plot(fastMA, color=color.green, linewidth=2)
plot(slowMA, color=color.red, linewidth=2)
The key is that your strategy uses strategy.entry() and strategy.close() calls. TradingView Copier Pro maps these to MT5 orders automatically.
Pro tip: Backtest your strategy thoroughly before going live. A TradingView bot is only as good as the strategy powering it. Target a minimum of 200 trades in backtesting with a profit factor above 1.5.
Step 2: Configure Webhook Alerts
Once your Pine Script strategy is on the chart, create an alert:
- Click the Alert button (clock icon) in TradingView
- Set Condition to your strategy name
- Under Notifications, check "Webhook URL"
- Paste your TradingView Copier Pro webhook URL
- In the Message field, use this JSON format:
{
"action": "{{strategy.order.action}}",
"symbol": "{{ticker}}",
"qty": "{{strategy.order.contracts}}",
"price": "{{close}}"
}
TradingView Copier Pro understands this format natively. When the strategy enters a long position, it sends "action": "buy". When it exits, "action": "close". No custom parsing needed.
Step 3: Connect to MT5 with TradingView Copier Pro
This is where your TradingView bot gets its execution engine. TradingView Copier Pro handles three critical things:
- Receives webhooks — via a built-in Cloudflare tunnel (no port forwarding or VPS needed)
- Parses signals — understands TradingView's JSON alert format out of the box
- Executes on MT5 — sends orders to one or multiple MT5 terminals via an auto-installed Expert Advisor
Setup takes under 5 minutes:
- Download and install TradingView Copier Pro
- Click "Detect MT5" — it finds your MetaTrader terminals automatically
- Click "Install EA" — the Expert Advisor installs with one click
- Copy your webhook URL from the Accounts tab
- Paste it into TradingView's alert webhook field
That's it. Your TradingView bot is now connected to MT5.
Step 4: Set Up Risk Management
A TradingView bot without risk management is a ticking time bomb. TradingView Copier Pro includes built-in risk controls:
- Daily drawdown limit — automatically stops trading if you lose more than X% in a day
- Max trades per day — prevents overtrading during volatile sessions
- Per-account risk sizing — set fixed lots or percentage-based sizing per MT5 account
- Symbol remapping — map TradingView symbol names to your broker's naming convention (e.g., GOLD → XAUUSD.c)
Recommended settings for beginners: Start with 1% risk per trade, max 5 trades per day, and a 3% daily drawdown limit. Scale up only after 30+ days of live performance data.
Step 5: Go Live — 24/7 Automation
Your TradingView bot is now live. Here's how to make it run 24/7:
Option A: Run on your PC — Keep your computer on with TradingView Copier Pro and MT5 running. Simple but your bot stops when your PC sleeps.
Option B: Run on a VPS — Set up a Windows VPS ($10–30/month) and install everything there. Your bot runs 24/7, even when your PC is off. See our complete VPS setup guide.
Monitor your bot's performance using TradingView Copier Pro's built-in dashboard — win rate, profit factor, Sharpe ratio, and a daily P&L calendar.
5 Mistakes That Kill TradingView Bots
- No backtesting — Running a live bot on a strategy you haven't backtested is gambling, not trading.
- Ignoring slippage — Backtest results don't include real-world slippage. Use a tool with sub-50ms execution to minimize it.
- Over-leveraging — A bot that risks 10% per trade will blow your account faster than manual trading.
- Wrong symbol mapping — TradingView says "GOLD" but your broker uses "XAUUSD.c". If you don't remap, trades fail silently.
- No monitoring — "Set and forget" works until it doesn't. Check your bot's audit log at least daily.
Frequently Asked Questions
Can TradingView run a trading bot?
TradingView itself doesn't execute trades, but it can trigger a trading bot through webhook alerts. When a Pine Script strategy generates a signal, TradingView sends a webhook to your bot (like TradingView Copier Pro), which then executes the trade on MT5 in under 50 milliseconds.
Is a TradingView bot legal?
Yes, automated trading via TradingView webhooks is legal in most jurisdictions. You're simply automating the execution of your own trading strategy. Check your broker's terms of service regarding automated trading and Expert Advisors.
How much does it cost to run a TradingView bot?
You need a TradingView plan with webhook alerts (starts at $14.95/month for Essential). TradingView Copier Pro is a one-time $97 purchase with no monthly fees. If running 24/7, a VPS costs $10–30/month. Total: under $50/month ongoing after the one-time bot purchase.
What is the best TradingView bot for MT5?
TradingView Copier Pro is the fastest TradingView bot for MT5, with sub-50ms execution, unlimited account support, and no monthly fees. It runs locally with a Cloudflare tunnel, making it faster and more reliable than cloud-based alternatives.
Can I copy trades to multiple MT5 accounts?
Yes — TradingView Copier Pro's Pro plan supports unlimited MT5 accounts. One webhook signal copies to all connected accounts simultaneously, with custom lot sizes per account.
Build Your TradingView Bot Today
Stop trading manually. TradingView Copier Pro connects your Pine Script strategy to MT5 in under 5 minutes.
Get TradingView Copier Pro →