How to send TradingView alerts to MT5 with a webhook

Turn a TradingView alert into a market order on MetaTrader 5: the webhook URL, the JSON alert message, sizing across accounts and closing positions from an alert.

TradingView is where many traders build and test their ideas. MetaTrader 5 is where their broker accounts live. TradingView cannot place orders on MT5 by itself, but it can send a webhook, an HTTP request to a URL you choose, every time an alert fires. Put something at that URL that speaks to MT5 and your alerts become trades.

This guide shows how to wire that up end to end with Atlaas: the webhook URL, the alert message, sizing across several accounts, closing positions from an alert and testing it safely.

What you need

  • A paid TradingView plan. TradingView only sends webhook alerts on paid plans.
  • Two-factor authentication on your TradingView account. TradingView requires it before it lets you use webhooks.
  • An MT5 account at any broker, running as an Atlaas terminal. Atlaas hosts it, so it keeps trading with your computer off.

How the pieces fit

  1. Your TradingView alert fires.
  2. TradingView sends a JSON message to your strategy's webhook URL.
  3. Atlaas checks the secret in the message and places a market order on every terminal attached to that strategy, each sized its own way.
  4. The orders carry the strategy's magic number, so their results roll up under the strategy in the dashboard.

Step 1: host your MT5 account

In the dashboard, open Terminals and add your MT5 account: login, password and broker server. Start on a demo account while you set this up.

Step 2: create a strategy

Open Strategies and choose New strategy. A strategy is a named magic number with a webhook:

  • Name, for example "London breakout".
  • Slug, which becomes part of the webhook URL, for example london-breakout. It cannot change later.
  • Magic number, which tags every order the strategy places.

Then attach terminals. For each one, set either a multiplier (the alert's volume is multiplied by it) or fixed lots (used whatever the alert says). That is how one alert can trade 0.10 lots on a small account and 1.00 lot on a large one.

Step 3: copy the webhook URL and the alert message

Open the strategy's Webhook dialog. It shows three things:

  • The URL, in the form https://api.atlaas.dev/hooks/<slug>.
  • The secret, starting with shsec_. Treat it like a password.
  • A ready-made TradingView alert message.

The alert message looks like this:

{
  "secret": "shsec_...",
  "action": "{{strategy.order.action}}",
  "symbol": "{{ticker}}",
  "volume": 0.1,
  "ts": "{{timenow}}"
}

TradingView replaces the parts in double braces when the alert fires. {{strategy.order.action}} becomes buy or sell for a strategy alert, {{ticker}} becomes the chart's symbol, and {{timenow}} becomes the time the alert fired. Atlaas uses that time to trade each alert once: a copy of the same alert sent again is refused, and so is one that arrives more than 5 minutes late.

Step 4: create the alert in TradingView

  1. Open the chart and create an alert on your strategy or indicator.
  2. In the alert's notification settings, turn on Webhook URL and paste the URL from step 3.
  3. Paste the alert message from step 3 into the Message field.
  4. Save the alert.

Strategy alerts and indicator alerts

{{strategy.order.action}} only exists for alerts created on a Pine Script strategy. For an alert on a plain indicator or a drawing, write the action yourself: one alert with "action": "buy" and another with "action": "sell".

When your broker names the symbol differently

{{ticker}} is TradingView's symbol, such as EURUSD or XAUUSD. If your broker uses a suffix, such as EURUSD.m or XAUUSDm, write the broker's symbol in the message instead of {{ticker}}.

Closing positions from an alert

Send close as the action to flatten:

{
  "secret": "shsec_...",
  "action": "close"
}

This closes every open position carrying the strategy's magic number, on every attached terminal. Add "symbol": "EURUSD" to close only that symbol's positions. Positions from other strategies, and trades you placed by hand, are left alone.

You can also send sl and tp prices with a buy or sell to place the stop loss and take profit with the order.

Testing without TradingView

Before you trust an alert with real money, send a signal yourself from the command line. With a demo MT5 terminal attached to the strategy:

curl -X POST https://api.atlaas.dev/hooks/london-breakout \
  -H "Content-Type: application/json" \
  -d '{ "secret": "shsec_...", "action": "buy", "symbol": "EURUSD", "volume": 0.01 }'

The reply comes back at once and says the signal was accepted:

{
  "success": true,
  "data": {
    "accepted": true,
    "signalId": "5b0c...",
    "strategy": { "id": "f3a1...", "slug": "london-breakout", "name": "London breakout" },
    "action": "buy",
    "terminals": 1,
    "followers": 0
  }
}

A moment later, Logs & events shows a "Signal received" event with what happened on every attached terminal: the fill price and ticket, or the reason a terminal could not trade, while the others still trade. Send "action": "close" the same way to close the test position.

Limits worth knowing

  • 60 signals a minute per strategy. More than that is refused until the minute passes.
  • Each alert trades once. Keep "ts": "{{timenow}}" in the message so a resent or replayed alert is refused. Without it, an identical message within 15 seconds counts as a repeat. Two alerts that send the same message can fire together (two conditions on one bar), and then only the first trades, so give each one its own id, such as "id": "long-{{timenow}}" and "id": "breakout-{{timenow}}".
  • Cap the open lots. Set a max open lots per terminal on the strategy, and a signal that would go past it is refused on that terminal.
  • Volumes round to 0.01 lots. Your broker's lot step for a symbol is not applied, so pick multipliers that land on it.
  • A paused strategy rejects signals until you resume it in the dashboard.
  • MT5 terminals only. Indian broker terminals have no magic numbers, so they cannot join a strategy.
  • Keep the secret out of shared charts. Anyone with the URL and the secret can send signals. Rotate it from the Webhook dialog if it leaks; the old one stops working straight away.

Summary

A TradingView alert becomes an MT5 order in four steps: host the account, create a strategy, copy its webhook URL and message, and paste both into the alert. Every order lands on the terminals you chose, at the size you set for each, and shows up under the strategy in the dashboard. The full request and response format is in the strategy webhook docs.