Skip to main content
Home / Guides / Automation and services / TradingView webhook to MT5
Guide · Automation and services · about 15 minutes

TradingView webhook to MT5, step by step.From an alert to an order, explained.

Written by Dan Freeman · last checked

TradingView can send an alert to a web address the moment it fires. That is a webhook. With the free PFX relay and PFX Executor, that alert becomes an order on your MetaTrader 5 account. This guide explains each link in the chain, then points you to the setup guides. Test everything on a demo account first.

~15 minto read
6 stepstick each one off
Paid TradingViewwebhooks need a paid plan
Freerelay and Executor
✓
Nothing trades while you read.

This guide explains the chain. The setup is in three short guides, linked in step 6.

0

Before you start

Two checks. Tick them as you go.

Words you'll see. Webhook = a web address an alert is sent to. Relay = the PFX service that receives it and holds it for your terminal. Executor = the free EA that places the order in MT5.
1

What a webhook is

An alert that calls a web address.

  1. A normal TradingView alert shows a pop-up or sends you a message. A webhook alert also sends its message to a web address you choose.
  2. MetaTrader 5 can't receive that message on its own. Something has to catch it and hand it to your terminal.
Not seeing it?

I can't see the Webhook URL box. It only appears on paid TradingView plans. Check your plan.

2

The chain, end to end

Four links, each doing one job.

  1. TradingView fires the alert and sends its message to your webhook address.
  2. The PFX relay receives it, runs five checks, and holds it for your terminal. A refused alert is logged with the reason.
  3. PFX Executor, an EA on your MT5 chart, collects it and checks it again: size, stop and spread.
  4. MetaTrader 5 sends the order to your broker.
If your terminal is closed, alerts wait at the relay and are collected when it comes back. But nothing trades until MT5 is running.
Not seeing it?

Do I need my own server? No. The relay is hosted for you. You can also run it yourself, covered in step 5.

3

The alert message

What you type in the alert's message box.

  1. The message is JSON. Only action and symbol are required.
  2. instance must match the Executor's Route key, so each terminal only takes its own alerts.
  3. Already have alerts written for PineConnector or TradersPost? The relay reads those formats as they are.
{ "instance": "Demo-1", "indicator": "PFX", "symbol": "{{ticker}}", "action": "buy", "lots": 0.01 }
The example is a placeholder. Use your own Route key and a size you would accept. The Executor's maximum lot size always applies.
Not seeing it?

TradingView says the message is invalid. Check it is valid JSON: quotes around every name, commas between lines.

4

Symbols and sizes

Where most first tests go wrong.

  1. Your broker may spell a symbol differently from TradingView, such as NAS100 against US100.cash. The Executor's Symbol aliases translate it.
  2. Run one Executor per symbol, and set its maximum lot size on purpose. It is a hard ceiling on any alert.
  3. In MT5, allow WebRequest for the relay address under Tools → Options → Expert Advisors. The Executor tells you at startup if it is missing.
Not seeing it?

The alert arrived but no trade opened. Check the symbol name first. It is the most common reason.

5

Hosted or your own relay

Two ways to run the middle link.

  1. Hosted: free with a PrecisionFX account. Each strategy gets its own webhook address, and the alert log shows every alert and every refusal.
  2. Your own: run the relay on your own PC or VPS with no account at all. Your keys stay on your machine.

Run the relay yourself · Is the hosted relay up right now?

Not seeing it?

Which should I pick? The hosted relay is quicker to start. Self-hosting suits you if you want no account.

6

Set it up

Three short guides, in order.

  1. Part 1 connects your terminal. Part 2 sends one test alert to a demo. Part 3 covers the stop levels and running it all day.
  2. MetaTrader 5 must be running for orders to be placed. For alerts while your PC is off, run it on a VPS.

Part 1: connect MT5 · Part 2: send a test alert · Part 3: run it reliably · Coming from PineConnector?

Not seeing it?

I use MetaTrader 4. The PFX Executor is for MetaTrader 5 only.

Your safety nets

Three things to keep in mind.

1

Demo first

Follow one alert all the way to a demo account before any real one.

2

Set a ceiling

Set the Executor's maximum lot size deliberately. It refuses any alert above it.

3

Missed or repeated signals

Automation adds the risk of a missed or repeated alert. Check the alert log after every change.

!

Prop-firm accounts

Your prop firm may restrict automation or webhook trading. Check its rules before you connect a challenge or funded account.

All done

You know the chain.Now connect your terminal.

Risk warning: Trading carries a high risk of loss and is not suitable for everyone. Automated trading carries the same risk as manual trading, plus the risk of a missed or repeated signal. MetaTrader and MQL5 are trademarks of MetaQuotes Ltd.; PrecisionFX is not affiliated with or endorsed by MetaQuotes.