TradingView Webhook Example for MT5: JSON Alerts That Work (2026)
Published October 29, 2026 · Updated November 19, 2026 · In Signal Copiers
You built a strategy in TradingView. Now you want each alert to open a trade in MetaTrader 5. This guide gives you a tradingview webhook example you can copy, then explains every field. You will know what to paste, where to paste it, and why each part matters.

What a TradingView webhook does
A webhook is a web address that TradingView calls when your alert fires. TradingView sends the text from the alert message box to that address. The text can be plain words or a line of JSON.
MetaTrader cannot receive that call on its own. A home PC or VPS does not normally have a public web address. A bridge sits in the middle. With our tradingview to mt5 connector, the alert goes to a private relay address. Then an Expert Advisor on your MetaTrader chart collects it and places the order.
Only the alert passes through the relay. Your broker login stays in your own terminal. The orders leave from your own MetaTrader 4 or MetaTrader 5.
Before you start, check two TradingView rules:
- Webhook alerts need a paid TradingView plan. A free plan cannot send them.
- The webhook URL must use https, on port 443 or 80. Other ports are rejected.
The basic TradingView webhook example
The simplest message that works is one short line of JSON. Paste it into the message box of any alert.
{"key":"gold@1","type":"buy","symbol":"XAUUSD","sl":2352,"tp":2364}
The sample alert tells the EA to buy gold. It sets a stop loss at 2352 and a take profit at 2364. Save this tradingview webhook example as your starting point. Next, let us go through each field, because each one has a job.

What each field in the JSON alert means
The message must name three things: a key, the symbol and the type. The other fields are optional.
- key: a short name you choose, such as gold@1. It tells the copier which of your strategies sent the alert.
- symbol: the market to trade, such as XAUUSD.
- type: the command. It is buy, sell, buyclose or sellclose.
- sl: your stop loss level, if your strategy worked one out.
- tp: your take profit level, if you have one.
You can also send an entry price. Distances in points work as well as exact prices. When the alert carries a level, the EA uses it. When it does not, the EA uses its own stop loss and target rules.
Some indicators can only send a plain line of text. Plain text needs a matching version of the EA, so tell us first.
Buy, sell and close commands
The type field holds one of four commands. Each one does a clear job:
- buy: opens a buy trade.
- sell: opens a sell trade.
- buyclose: closes that strategy’s buys and deletes its pending buy orders.
- sellclose: does the same for sells and pending sell orders.
A close alert only touches trades with the same key. So one strategy cannot close the trades of another. This tradingview webhook example closes the buys of the gold strategy:
{"key":"gold@1","type":"buyclose","symbol":"XAUUSD"}
Your daily limits never hold back a close alert. Taking risk off should not wait.

Using TradingView placeholders in the alert
Typing a fixed alert works for a manual setup. A strategy needs the message to change by itself. TradingView placeholders do that. When the alert fires, TradingView swaps each one for a real value.
{{ticker}} the chart symbol, such as XAUUSD
{{close}} the bar close price
{{time}} the bar time
{{strategy.order.action}} buy or sell, from your strategy
{{strategy.order.contracts}} the order size in your strategy
Now put them into the JSON. This tradingview webhook example lets one strategy alert send both buys and sells:
{"key":"gold@1","type":"{{strategy.order.action}}","symbol":"{{ticker}}"}
Keep the quote marks around each placeholder. Otherwise the JSON breaks. You do not need {{strategy.order.contracts}} here. The alert decides the direction, and you decide the size inside the EA.
How the EA turns the alert into an MT5 order
After TradingView posts your tradingview webhook example, the steps are short:
- The alert waits at your private relay address.
- The EA polls that address four times a second by default.
- It reads the key, symbol and type, plus any entry, stop loss and take profit.
- Your lot rule sizes the trade. It can be a fixed lot, automatic money management, risk percent or a risk amount.
- The order goes in on your terminal, with the stop and target attached.
Every key gets its own slot. The slot has its own magic number, its own position caps and its own close alerts. As a result, you can run several strategies on one terminal and still tell them apart.

Entry modes for alerts with a price
When your tradingview webhook example carries a price, the copier lets you choose one of three modes:
- Market: ignore the price and fill straight away.
- Alert price, with a fallback: place a pending order at your price. If the market sits too close, fill at market instead.
- Alert price only: never send a market order. If the pending order cannot go in, the trade does not happen.
Two guards also help. A pending order expires after a time you set. And the EA rejects any alert price too far from the market.
Set up your tradingview webhook example in 5 steps
- Attach the EA to a chart of each symbol you trade. A gold alert needs a gold chart.
- In MetaTrader, open Tools, Options, Expert Advisors. Tick Allow WebRequest and add https://algodevelop.com.
- In TradingView, paste your relay address into the Webhook URL box of the alert.
- Put your JSON line, with your key, into the alert message box.
- Fire one alert by hand and watch the dashboard. Then run it on a demo account for a few days.
TradingView’s own guide on how to configure webhook alerts shows where the Webhook URL box sits. For the full walk-through, read our guide on how to connect TradingView to MT4/MT5.
Common mistakes and how to fix them
Most failed alerts come from small slips, not from the strategy. Check these first:
- Broken JSON. A missing quote or comma breaks the whole line. Copy the tradingview webhook example above and change one value at a time.
- Wrong symbol name. Your broker may use XAUUSD.m or #XAUUSD. Set the prefix and suffix once in the EA.
- No WebRequest permission. If MetaTrader blocks the relay address, the EA says so plainly.
- Late alerts. The EA ignores alerts older than the age you set. An old alert never fills at a new price.
- Test alerts. TradingView test fires do nothing. Repeats of the same alert also count only once.
Still stuck? Switch on diagnostics mode. The log then spells out each decision the EA makes.
Where your alerts come from
If you still need the strategy itself, start there. Our Pine Script development service can write it. Or read Pine Script vs MQL to choose where your logic should live. For a fully done-for-you setup, see TradingView strategy automation.
Ready to test it? Download the TradingView to MT4/MT5 copier, paste this tradingview webhook example into an alert, and try it free for 2 days. Message us on WhatsApp for your trial key, and we will help you set it up.
Frequently asked questions
Do I need a paid TradingView plan for webhooks?
Yes, you do. That is TradingView’s rule, not ours.
What is the simplest TradingView webhook example for MT5?
One short line of JSON with a key, the symbol and the type. For example, a key of gold@1, a symbol of XAUUSD and a type of buy. The sl and tp fields are optional.
Which commands can the type field use?
The type field can use buy, sell, buyclose or sellclose. A close command only closes trades with the same key, and it also deletes pending orders on that side.
Can my alert send its own stop loss and take profit?
Yes. Send them in the alert, and the EA uses them whenever they are there. Without them, the EA falls back on its own rules.
How fast does the alert reach MetaTrader 5?
The EA polls your private relay address four times a second by default. So MetaTrader sees a new alert within moments, not minutes.
Software and automation development service only. This is not investment advice and there is no guarantee of profit. Trading carries risk, so test on a demo account first. Tools run on your own account under your control.
Want this built for you?
We develop it as a service — reliable, tested, and yours to own.
Message Us on WhatsApp