Start free
TheConnector Blog

How to connect TradingView to MT4 with a webhook

A practical guide to route TradingView alerts to MT4 through TheConnector, with payload examples, Pine Script notes and risk checks.

2026-05-10 TradingView MT4 webhook Pine Script automation
Trading automation guide

How to connect TradingView to MT4 with a webhook

A practical guide to route TradingView alerts to MT4 through TheConnector, with payload examples, Pine Script notes and risk checks.

TheConnector is a technical routing and automation tool. It does not provide financial advice, promise gains or remove trading risk.

Who this is for

This guide is for independent traders who already have a TradingView idea and want to send it to an MT4 account without maintaining their own server. TheConnector receives the TradingView webhook, checks the account route, then forwards the command to the MT4 robot connected to your broker account.

Flow to understand

  • TradingView Alert creates the signal
  • TheConnector receives the webhook
  • Routing and risk parameters are read from the account configuration
  • The MT4 robot receives only the command that is still valid now
  • The order result is visible from the dashboard when your plan includes the relevant history

Basic webhook payload

Start with a small payload and one demo account. Keep the message explicit so it is easy to audit later.

{
  "symbol": "EURUSD",
  "side": "buy",
  "risk": "1",
  "sl": "20",
  "tp": "40",
  "comment": "tv-mt4-test"
}

Pine Script example

Use alert() only when your condition is confirmed. Avoid sending several alerts on the same candle unless your strategy is designed for it.

//@version=5
indicator("TheConnector MT4 test", overlay=true)
longSignal = ta.crossover(ta.sma(close, 20), ta.sma(close, 50))
if longSignal and barstate.isconfirmed
    alert('{"symbol":"EURUSD","side":"buy","risk":"1","sl":"20","tp":"40"}', alert.freq_once_per_bar_close)

Common mistakes

  • The MT4 robot is not running or algo trading is disabled
  • The TradingView alert uses the wrong webhook URL or access key
  • The broker symbol is not exactly the same as the dashboard mapping
  • The payload sends a risk value that does not match your account rules
  • The strategy sends too many alerts too quickly for the plan quota

Risk and limits

TheConnector is a technical routing tool. It does not provide financial advice, does not promise gains and cannot remove market, broker or execution risk. Test on a demo account, keep position size conservative and verify every TradingView condition before using a live account.