Start free
TheConnector Blog

How to send a Pine Script alert to MT5

A clear method to turn a Pine Script condition into a controlled MT5 automation signal through a TradingView webhook.

2026-05-09 Pine Script MT5 TradingView webhook automation
Trading automation guide

How to send a Pine Script alert to MT5

A clear method to turn a Pine Script condition into a controlled MT5 automation signal through a TradingView webhook.

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

Start with the signal, not the order

The safest MT5 automation flow begins in Pine Script with a clear condition. The webhook should describe what happened, not hide the whole strategy inside a vague text message.

  • Confirm the Pine Script condition on bar close
  • Send one JSON payload per signal
  • Include symbol, side, risk and optional stop or target values
  • Let the TheConnector account configuration handle routing to the MT5 robot

Example alert message

{
  "platform": "mt5",
  "symbol": "XAUUSD",
  "side": "sell",
  "risk": "0.5",
  "sl": "18",
  "tp": "36",
  "source": "pine-breakout"
}

Pine Script pattern

//@version=5
indicator("MT5 webhook signal", overlay=true)
breakout = close > ta.highest(high, 20)[1]
payload = '{"platform":"mt5","symbol":"XAUUSD","side":"buy","risk":"0.5","sl":"18","tp":"36","source":"pine-breakout"}'
if breakout and barstate.isconfirmed
    alert(payload, alert.freq_once_per_bar_close)

MT5-specific checks

MT5 symbols often differ between brokers. Check suffixes, contract size, price precision and minimum volume before sending a live signal. If a symbol is XAUUSD.r at the broker but XAUUSD in TradingView, configure the mapping before the alert goes live.

Useful test routine

  • Send one alert from a demo chart
  • Check that TheConnector receives the webhook
  • Check that the MT5 account is live
  • Compare the order request with your expected risk
  • Only then repeat with the real symbol list

No execution promise

TheConnector forwards technical instructions. Broker availability, spreads, slippage, rejected orders and platform connectivity can still affect the result. No automation tool can promise profit or guaranteed execution.