TradingView–MetaTrader Integration — Webhook Alerts That Place Real Trades
We build the missing bridge: a secure server that receives TradingView webhook alerts, validates them, applies your risk rules and executes the order on MetaTrader 4/5 or a crypto exchange.
TradingView cannot place trades on MetaTrader by itself, but its alerts can send a webhook, an HTTP POST, to a server you control. ExpertNevees builds that server and the MetaTrader-side executor: it authenticates each alert, checks duplicates and risk rules, and sends the order to MT4/MT5 or an exchange. Typical delivery is 10–15 days, including hosting guidance.
How the Bridge Works
TradingView Alert
Webhook Server
Executor
Feedback
TradingView Webhook Requirements You Must Design Around
| Requirement | What TradingView documents | What it means for the build |
|---|---|---|
| Plan and security | Webhook alerts need a paid plan and two-factor authentication enabled on the account | Confirm your TradingView plan before starting |
| Ports | Webhooks are sent to ports 80 and 443 only | The server must listen on standard HTTP/HTTPS ports behind a reverse proxy |
| Timeout | TradingView cancels a request that takes longer than about 3 seconds | The server acknowledges immediately and processes the order asynchronously |
| Content type | Valid JSON is sent as application/json, anything else as text/plain | The parser must tolerate both content types |
| Sensitive data | Do not put credentials in the alert message | Authentication uses an unguessable URL token, never account passwords |
Always check TradingView’s current webhook documentation, because plan requirements and limits can change. Source: TradingView webhook guide.
A Webhook Receiver That Acknowledges Fast and Rejects Bad Requests
import asyncio
import hmac
import json
import os
from fastapi import FastAPI, HTTPException, Request
app = FastAPI()
URL_TOKEN = os.environ["WEBHOOK_URL_TOKEN"] # long random string, part of the URL
orders: asyncio.Queue = asyncio.Queue()
seen_ids: set[str] = set() # simple replay / duplicate guard
@app.post("/webhook/{token}")
async def webhook(token: str, request: Request):
if not hmac.compare_digest(token, URL_TOKEN):
raise HTTPException(status_code=404) # do not reveal that the endpoint exists
raw = await request.body() # TradingView may send text/plain
try:
data = json.loads(raw)
except json.JSONDecodeError:
raise HTTPException(status_code=400, detail="payload must be JSON")
alert_id = str(data.get("id", ""))
if alert_id and alert_id in seen_ids:
return {"status": "duplicate"} # same alert delivered twice: ignore
seen_ids.add(alert_id)
intent = {k: data.get(k) for k in ("symbol", "action", "volume", "sl", "tp")}
await orders.put(intent) # a worker validates and executes later
return {"status": "queued"} # answer well inside the ~3 s limit
The matching TradingView alert message could be: {"id":"{{ticker}}-{{time}}","symbol":"{{ticker}}","action":"buy","volume":0.1}. Placeholders such as {{ticker}} are filled in by TradingView when the alert fires.
Safeguards Built Into Every Bridge
- ●Authentication by secret URL token and optional IP allow-listing of TradingView’s published addresses.
- ●Idempotency: the same alert delivered twice never opens two trades.
- ●Symbol mapping: TradingView ticker names are mapped to your broker’s symbol names (suffixes, prefixes, CFD naming).
- ●Pre-trade checks: spread, trading hours, max exposure and daily-loss limits are applied before every order. See Capital & Risk Management.
- ●Dead-letter log and alerts: any rejected or failed order is recorded and sent to your Telegram.
- ●Heartbeat: the executor reports that it is alive, so you notice a disconnected terminal immediately.
Delivery Steps
Review your TradingView strategy
We check that alerts fire at the moments you intend. Strategy logic that repaints or acts on unconfirmed bars is flagged first.
Design the alert payload
A JSON schema for actions such as buy, sell, close, move stop, with symbol, size and optional stop and target.
Build server and executor
Webhook server, queue, and the MT4/MT5 Expert Advisor or exchange connector.
Test on demo
End-to-end tests with real TradingView alerts on a demo account, including failure scenarios.
Deploy and hand over
Hosting on a VPS with auto-restart, documentation and monitoring. See VPS Setup & Bot Infrastructure.
Delivery, Support & Guarantee
Timelines are indicative. The exact price and delivery date are confirmed in writing before work starts, with no hidden costs. Payment: 50% advance, 50% after your approval (USDT or bank wire).
Frequently Asked Questions
Can TradingView trade directly on MetaTrader?
Not by itself. TradingView alerts can send a webhook, and a bridge such as the one we build receives it and sends the order to MetaTrader 4/5 or an exchange.
Do I need a paid TradingView plan?
Yes. TradingView documents that webhook alerts require a paid plan and two-factor authentication on your account. Check TradingView’s current plan details before starting.
Is the connection fast enough for trading?
The webhook hop typically adds a small delay to a trade placed at bar close, which suits most swing and intraday strategies. It is not intended for latency-critical scalping.
What if TradingView sends the same alert twice?
The bridge uses an alert ID to detect duplicates, so a repeated delivery never opens a second trade.
Does the bridge work with a Pine strategy as well as an indicator?
Yes. Both can fire alerts. Strategy alerts follow the order logic of the Pine script. We review them for repainting and bar-close behaviour first.
Can the same bridge send orders to a crypto exchange?
Yes. The executor can be an exchange connector instead of, or in addition to, MetaTrader. See Crypto Trading Bot Development.
Should I instead convert my Pine script to an Expert Advisor?
If you want full independence from TradingView and tick-level control, conversion is better. See TradingView to MetaTrader Conversion.
Official Documentation & Sources
- How to Configure Webhook AlertsTradingView SupportView Docs ↗
- FastAPI Documentationfastapi.tiangolo.comView Docs ↗
Automate Your TradingView Alerts Into Real Orders
Send your TradingView script or alert idea. We confirm what is feasible and quote it in writing.