TradingView's webhook feature lets you send alert data to any URL when your conditions trigger. Combined with a signal bridge and an MT5 Expert Advisor, this creates a fully automated trading pipeline. Here's exactly how to set it up.

What is a TradingView Webhook?

A webhook is an HTTP POST request that TradingView sends to a URL you specify whenever an alert fires. The request body contains whatever message you configured in the alert — typically a JSON payload with trade instructions.

Unlike push notifications or email alerts, webhooks are machine-readable. A signal server can parse the JSON, validate it, and queue it for execution on MT5 — all in under a second.

Prerequisites

Before you start, you need:

  1. TradingView Pro or higher — Webhooks aren't available on the free plan
  2. A signal bridge service — Something to receive the webhook and serve it to MT5 (like iNakaTrader)
  3. MetaTrader 5 — Installed on a VPS or always-on computer
  4. An Expert Advisor — Running in MT5 to poll for and execute signals

Step-by-Step Webhook Setup

1. Get Your Webhook URL

Your signal bridge provider gives you a webhook URL. With iNakaTrader, it looks like:

https://your-server.com/webhook?token=YOUR_LICENSE_KEY

The token parameter authenticates your requests. Keep this URL private — anyone with it can send signals to your account.

2. Create a TradingView Alert

On your TradingView chart:

  1. Click the Alert button (clock icon) or press Alt+A
  2. Set your condition (indicator crossing, price level, strategy order, etc.)
  3. Under Notifications, check Webhook URL and paste your URL
  4. In the Message field, enter your JSON payload

3. Format the Alert Message

The message format depends on your signal bridge. Here's the iNakaTrader format:

Simple market order:

{
  "action": "alertX",
  "symbol": "EURUSD",
  "magic": 1001,
  "direction": "BUY",
  "size": 0.1,
  "sl": 30,
  "tp": 60
}

With trailing stop and breakeven:

{
  "action": "alertX",
  "symbol": "XAUUSD",
  "magic": 1002,
  "direction": "SELL",
  "size": 0.05,
  "sl": 100,
  "tp": 200,
  "trail_activate": 50,
  "trail_distance": 25,
  "move_sl_after": 30,
  "move_sl_to": 5
}

Close all positions:

{
  "action": "alertZ",
  "magic": 1001,
  "close": "all"
}

4. Using TradingView Placeholders

TradingView supports dynamic placeholders in alert messages. These are replaced with real values when the alert fires:

Placeholder Value
{{ticker}} Symbol name (e.g., EURUSD)
{{close}} Current price
{{time}} Alert timestamp
{{strategy.order.action}} "buy" or "sell" (Pine Script strategies)
{{strategy.order.id}} Order ID from strategy

Example using placeholders:

{
  "action": "alertX",
  "symbol": "{{ticker}}",
  "magic": 1001,
  "direction": "{{strategy.order.action}}",
  "size": 0.1,
  "sl": 50
}

Webhook Authentication

Security matters — you don't want unauthorized signals executing trades on your account. There are three common authentication methods:

URL Token (Simplest)

Include your license key as a URL parameter. TradingView can't send custom headers, so this is the most compatible method:

https://server.com/webhook?token=YOUR_KEY

Header Secret

If your client supports custom headers (not TradingView directly, but programmatic senders):

X-Secret-Token: YOUR_KEY

HMAC-SHA256 (Most Secure)

For programmatic integrations, sign the request body with a shared secret. The server verifies the signature and rejects tampered requests. Also includes a timestamp to prevent replay attacks.

Alert Types for Different Strategies

Two-Step Confirmation (alertX + alertY)

For strategies that need confirmation from multiple conditions:

Alert 1 (arms the trade):

{"action": "alertX", "symbol": "GBPUSD", "magic": 3001, "direction": "BUY", "size": 0.1, "sl": 40, "tp": 80}

Alert 2 (confirms and executes):

{"action": "alertY", "magic": 3001}

The trade only executes if alertY arrives after alertX. This prevents single-alert false triggers.

Pine Script Mode

If you're running a strategy() in Pine Script, enable Pine Script mode to map strategy.entry() and strategy.close() directly:

Enable with an alertS:

{"action": "alertS", "symbol": "EURUSD", "magic": 4001, "pine_script": true, "size": 0.1, "sl": 25, "tp": 50}

Then use TradingView's built-in strategy alert with {{strategy.order.action}} — entries and exits are forwarded directly to MT5.

Guarded Close (alertZ1 + alertZ2)

Prevent accidental liquidation from false alerts by requiring two close signals:

{"action": "alertZ1", "magic": 1001}

Followed within 5 minutes by:

{"action": "alertZ2", "magic": 1001, "close": "all"}

If alertZ2 doesn't arrive within the timeout, the close is cancelled.

Troubleshooting Common Issues

"Webhook not firing"

"Alert fires but no trade"

"Wrong lot size or SL/TP"

"Duplicate trades"

Best Practices

  1. Always use JSON format — It's machine-parseable and less error-prone than plain text
  2. Include a Magic Number — This isolates strategies and prevents signal conflicts
  3. Set alert expiry — Don't leave alerts running forever; review them weekly
  4. Use Once Per Bar Close — Prevents duplicate signals from price oscillation within a candle
  5. Test on demo first — Always verify the full pipeline before going live
  6. Monitor your signal server — Check logs regularly for failed deliveries or auth errors

FAQ

How many webhooks can TradingView send per minute? TradingView doesn't publish hard rate limits, but in practice, alerts fire reliably up to about 1 per second. If you have dozens of alerts firing simultaneously, some may be delayed.

Can I send webhooks to multiple servers? Each TradingView alert has one webhook URL. To send to multiple destinations, you'd need a relay service or duplicate alerts.

Does the webhook retry on failure? TradingView does not retry failed webhook deliveries. If your server is down when the alert fires, the signal is lost. This is why signal queue persistence on the server side is important.


Set up automated webhook trading in minutes. Get started with iNakaTrader — TradingView to MT5, fully automated.

Risk Disclaimer: Trading forex and other financial instruments involves substantial risk of loss and is not suitable for all investors. Past performance does not guarantee future results. Only trade with capital you can afford to lose. iNakaTrader provides signal execution tools, not financial advice.