Home › Guides

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.

Quick setup: in the HostMT5 dashboard, open the account's webhook and copy its secret URL (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

  1. Your indicator or strategy triggers an alert on TradingView.
  2. TradingView sends the alert message (HTTP POST) to your webhook URL.
  3. 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.
  4. 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

ActionWhat it does
buy, sellMarket order (aliases: long, short)
buy_limit, sell_limit, buy_stop, sell_stopPending order at price (or buy/sell with type=limit|stop)
closeClose by symbol or ticket; add pct=50 for a partial close (aliases: exit, flat)
close_buy, close_sellClose only longs or only shorts (closelong, closeshort)
close_allClose every position
modifySet a new SL and/or TP
breakevenMove the stop loss to the entry price
cancel, cancel_buy, cancel_sellDelete 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

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 saysFix
unknown actionUse 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 pausedSwitch the pause off in the dashboard (AI & API tab).
symbol missingAdd symbol (or {{ticker}}).
lots (or risk %) missingOpening orders need lots or risk.
price missing for a pending orderLimit and stop orders need price.
terminal not connectedOpen the account in the dashboard and check it is logged in to the broker.

TradingView's own requirements

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.

Host your MT5 in the cloud, free

Real MetaTrader 5 in any browser. EAs 24/7, copy trading, TradingView webhooks. No card needed.

Start free →
More guides

All guides · HostMT5 facts