TradingView alerts to MT5 orders with a webhook
Updated 2026-11-24 · HostMT5 guides
TradingView can't place orders in MetaTrader 5 on its own, but its alerts can call a webhook URL. Point that webhook at a bridge connected to your MT5 account and every alert becomes an order. With HostMT5 the bridge is built into your hosted terminal, so there is no EA to install and no VPS to keep on.
https://hostmt5.com/hook/<secret>). In TradingView, create an alert, tick Webhook URL, paste it, and write a message such as buy EURUSD 0.1 sl=1.085 tp=1.095. Every call is logged in your dashboard.How the flow works
- Your indicator or strategy triggers an alert on TradingView.
- TradingView sends the alert message (HTTP POST) to your webhook URL.
- HostMT5 reads the message, finds your hosted MT5 account by the secret in the URL, matches the symbol to your broker's name and places the order.
- The result (filled, or the exact reason it was refused) shows in the dashboard log.
Your MT5 terminal is hosted and always on, so alerts are executed even when your computer is off. Keep the URL private: anyone who has it can send orders to that account. You can rotate it from the dashboard at any time.
Message formats
HostMT5 accepts four formats, so many alert templates written for other bridges can be reused. All four map to the same order.
1. JSON
{"action": "buy", "symbol": "EURUSD", "volume": 0.1, "sl_pips": 20, "tp_pips": 40, "id": "{{timenow}}"}
{"action": "sell", "symbol": "XAUUSD", "risk": 1, "sl_pips": 30, "tp_pips": 60}
In JSON, risk means % of balance lost if the stop is hit (above 0, up to 10). Size can also be volume, lots or qty. Unknown fields are rejected with a clear error, so a typo in an alert template never trades differently from what you meant.
2. KEY=VALUE; (bridge style)
ACTION=buy;SYMBOL=EURUSD;VOL=0.1;SL=200;TP=400
Here SL/TP are in points; use SLPRICE/TPPRICE for exact prices.
3. PineConnector-style comma format
LicenseID,buy,EURUSD,vol_lots=0.01,sl_pips=20,tp_pips=40
PineConnector messages work unchanged. The first field (a licence ID) is accepted and ignored. Supported: vol_lots, vol_pct (% of balance at risk), sl_pips, tp_pips, sl_price, tp_price, plus the legacy risk= (lots) and sl=/tp= (pips). See PineConnector alternative.
4. Plain words
buy EURUSD 0.1 sl_pips=20 tp_pips=40
close_all
Actions
| Action | What it does |
|---|---|
buy, sell | Market order (aliases: long, short) |
buy_limit, sell_limit, buy_stop, sell_stop | Pending order at price (or buy/sell with type=limit|stop) |
close | Close by symbol or ticket; add pct=50 for a partial close (aliases: exit, flat) |
close_buy, close_sell | Close only longs or only shorts (closelong, closeshort) |
close_all | Close every position |
modify | Set a new SL and/or TP |
breakeven | Move the stop loss to the entry price |
cancel, cancel_buy, cancel_sell | Delete pending orders |
Stops can be prices (sl, tp), pips (sl_pips, tp_pips) or points (sl_points, tp_points); send one kind per side.
Safety options
- id: an alert repeated with the same id within 10 minutes is ignored, so a TradingView retry cannot double your position.
{{timenow}}works well. - spread: skip the trade if the spread is wider than this many pips.
- Per-webhook settings in the dashboard: a pause switch, default lots, maximum lots, allowed symbols and symbol mapping.
Using TradingView placeholders
For a Pine Script strategy, let TradingView fill in the side, symbol and size:
{"action": "{{strategy.order.action}}", "symbol": "{{ticker}}", "volume": {{strategy.order.contracts}}, "id": "{{timenow}}"}
Exchange prefixes such as OANDA:EURUSD are stripped automatically, and symbols are matched to your broker's names, for example XAUUSD to XAUUSD.pro.
Troubleshooting
| Log says | Fix |
|---|---|
| unknown action | Use one of the actions in the table above. |
| unknown field(s) | A JSON key is misspelled or not supported; the error lists the allowed keys. |
| webhook is paused | Switch the pause off in the dashboard (AI & API tab). |
| symbol missing | Add symbol (or {{ticker}}). |
| lots (or risk %) missing | Opening orders need lots or risk. |
| price missing for a pending order | Limit and stop orders need price. |
| terminal not connected | Open the account in the dashboard and check it is logged in to the broker. |
TradingView's own requirements
- Webhook alerts need a paid TradingView plan: they are listed for Essential, Plus, Premium, Expert and Ultimate, not the free Basic plan (TradingView pricing).
- Two-factor authentication must be on in your TradingView account, only ports 80 and 443 are accepted, and a request that takes longer than three seconds is cancelled (TradingView: About webhooks). The HostMT5 URL uses HTTPS on port 443 and always answers within 2.5 seconds: with the result if the broker has filled, otherwise "accepted" while the order finishes in the background, with the outcome in your webhook log.
If alerts never show up in the HostMT5 log, check those three first.
Related
FAQ
Can TradingView place trades in MT5?
Not by itself. A TradingView alert can call a webhook URL; a bridge such as HostMT5 receives the message and places the order in your MT5 account.
Do I need an EA or a VPS for TradingView to MT5?
Not with HostMT5. The webhook goes straight to your hosted MT5 terminal, so no bridge EA and no separate VPS are needed.
What message format does HostMT5 accept?
JSON such as {"action":"buy","symbol":"EURUSD","volume":0.1,"sl_pips":20,"tp_pips":40}, KEY=VALUE such as ACTION=buy;SYMBOL=EURUSD;VOL=0.1, PineConnector syntax unchanged such as LicenseID,buy,EURUSD,vol_lots=0.01,sl_pips=20,tp_pips=40, or plain words such as buy EURUSD 0.1 sl_pips=20.
Can I size trades by risk instead of lots?
Yes. In JSON, {"action":"sell","symbol":"XAUUSD","risk":1,"sl_pips":30} risks 1% of the balance to the stop loss.
How do I stop TradingView sending the same order twice?
Add an id such as "{{timenow}}" to the message. HostMT5 ignores a repeated id within 10 minutes.
Real MetaTrader 5 in any browser. EAs 24/7, copy trading, TradingView webhooks. No card needed.
Start free →- A free MT5 VPS alternative: hosted MetaTrader 5, free during launch
- Do you still need an MT5 VPS?
- How to run an MT5 Expert Advisor 24/7 without your PC
- Copy trades between MT5 accounts at different brokers
- A MetaApi alternative for traders, not only developers
- A free PineConnector alternative with MT5 hosting included
- The full MT5 terminal in your browser
- Let an AI assistant work with your MT5 account
- Use MT5 from Python on Mac, Linux or a notebook
- A REST API and live stream for MetaTrader 5
- Let Claude or ChatGPT build and run your MT5 EA
- Download years of MT5 price history to CSV
- Moving Skynet MT5 alerts to HostMT5