A TradingView bot is a direct 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, automatically, for as long as the app and MT5 are running.
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. Setup takes 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 most direct and 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, and the stop price used for position sizing
- Expert Advisor on MT5 polls the app's local server every half second over HTTP and executes the trade
- Trade is passed to MT5 in under a second after the alert reaches your PC
Total time from alert to fill also depends on TradingView's webhook delivery and your broker.
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 (Pro version)
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}}",
"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 needed; a VPS is optional, but your PC must stay on)
- Parses signals — understands TradingView's JSON alert format out of the box
- Executes on MT5 — sends orders to one MT5 terminal (or multiple on the Pro version) via an auto-installed Expert Advisor
Setup takes 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; then attach it to a chart in MT5, enable Algo Trading, and allow WebRequest for http://127.0.0.1:3000 in MT5's options
- 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 — blocks new entries for the rest of the day if you lose more than X% in a day (it does not close open positions)
- Max trades per day — blocks new entries for the rest of the day once the limit is reached
- 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. Automation removes the manual entry delay, but slippage still depends on your broker and the market.
- 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 passes the trade to MT5 in under a second.
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 purchase from $47 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 a TradingView bot built for MT5, with a sub-second hand-off to MT5, unlimited account support on the Pro version, and no monthly fees. It runs locally on your own PC with a built-in Cloudflare tunnel, so your signals avoid an extra third-party relay server.
Can I copy trades to multiple MT5 accounts?
Yes — TradingView Copier Pro's Pro version 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 minutes.
Get TradingView Copier Pro →