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.

TradingView webhook example sending a JSON alert to MetaTrader 5

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:

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.

Diagram of a TradingView alert passing through a private relay to the Expert Advisor in MetaTrader

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.

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:

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.

Diagram of one alert feed reaching several MT4 and MT5 accounts, split by strategy key

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:

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.

Five setup steps for connecting TradingView alerts to MetaTrader

Entry modes for alerts with a price

When your tradingview webhook example carries a price, the copier lets you choose one of three modes:

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

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:

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
WhatsApp