Guide · TradingView

Connect TradingView alerts to MT4 and MT5

Send a TradingView alert, including one from a Pine Script strategy, to a private webhook, and VPS One turns it into an order on your MetaTrader terminal. The order is confirmed on Telegram first, or executed automatically if you choose.

Last updated

What you need

  • A running VPS One Trading VPS (MT4 or MT5).
  • A paid TradingView plan with two-factor authentication on. TradingView only allows webhooks on paid plans with 2FA.
  • For Telegram confirmation: Telegram linked in your profile.

Setup

  1. Turn on TradingView alerts. In the VPS One dashboard, open Trading accounts, then your MT4/MT5 account card, then "AI & TradingView trading", and click "Turn ON TradingView alerts".
  2. Choose how orders run. Pick "Ask me on Telegram first" (link Telegram under Profile) or "Execute automatically".
  3. Create your webhook URL. Click "Create webhook URL" and copy it. It is shown only once. Anyone with it can send alerts to this account, so keep it private.
  4. Set your limits. Set max lot per order, max orders per day, whether a stop loss is required, and optionally a symbol whitelist. Live accounts are refused until you allow them.
  5. Create the alert in TradingView. In the alert's Notifications tab, tick Webhook URL, paste your URL, and put a JSON message in the Message field.
  6. Test on a demo account. Trigger the alert once. The result appears under Recent orders on the account card, with the reason if it was refused.

Alert message format

The Message field must be JSON. These fields are understood:

actionbuy, sell, close or close_all. {{strategy.order.action}} works too.
symbolThe instrument. {{ticker}} is fine: exchange prefixes like OANDA: are removed.
lotsVolume for buy/sell, for example 0.10.
sl, tpStop loss and take profit as prices. 0 means none.
sideClose only: buy or sell to close just that side.
idOptional. An alert with an id already received is ignored, so a repeat never opens a second order.
commentOptional text shown to you in Telegram and in the history.

Examples

Pine Script strategy (buy and sell from the strategy itself):

{"action":"{{strategy.order.action}}","symbol":"{{ticker}}","lots":0.10,"sl":0,"tp":0,"id":"{{timenow}}","comment":"{{strategy.order.comment}}"}

A single buy with stop loss and take profit:

{"action":"buy","symbol":"{{ticker}}","lots":0.05,"sl":2331.0,"tp":2368.0,"id":"{{timenow}}"}

Close all BUY positions on the chart's symbol:

{"action":"close","symbol":"{{ticker}}","side":"buy"}

Close every open position:

{"action":"close_all"}

Symbol names

Broker suffixes are matched automatically: XAUUSD finds XAUUSDm, XAUUSD.f or GOLD. If your broker uses a completely different name, add a line such as US30=DJ30 under “Symbol names that differ at your broker”.

Troubleshooting

“a stop loss is required”Stop loss is required by default. Send an sl price, or switch the requirement off.
“exceeds this account's limit”Lower lots or raise Max lot per order.
“LIVE account … isn't allowed”Tick “Allow on a LIVE account” once you've tested on demo.
Nothing arrivesCheck the URL was pasted in full, the alert has Webhook URL ticked, and your TradingView plan supports webhooks.

Up to 30 alerts per minute per account. Every alert, accepted or refused, is recorded with the reason on the account card.

Ready to automate your TradingView strategy?

Get a MetaTrader terminal that listens to your alerts 24/7.