Set up your TradingView alerts to send signals

Connect a TradingView alert to your strategy, write the right message, pick index and commodity symbols, and understand an alert that fails.

7 min read

Your TradingView alerts send their signals to an address that belongs to your strategy. The Expert Advisor then receives them in MetaTrader. Webhooks require a paid TradingView plan.

Get the URL and the token

  1. Open Strategies, then New Strategy: the assistant guides you in four steps (name, prepare the script, test, plug) and shows your token and the webhook URL. The form with a description and Trading Symbols remains available with Full form. With ProTradingConnector alone, one personal strategy is allowed: if the button does not show, use the existing one or replace it.

  2. On the strategy card, copy the Webhook URL (Copy URL) and the Token (Copy token).

The token identifies your strategy: do not share it. If you click Regenerate token, the old one stops working at once and every alert must be updated.

The message format

The message is plain text (not JSON), with no spaces:

TOKEN:positionId;SYMBOL;BUY;entry;SL;TP
TOKEN:positionId;SYMBOL;SELL;entry;SL;TP
TOKEN:positionId;SYMBOL;BE
TOKEN:positionId;SYMBOL;SL;entry;newSL
TOKEN:positionId;SYMBOL;CLOSE
  • positionId: one unique identifier per position. A position's BE, SL and CLOSE must reuse exactly the one of its BUY or SELL. Build it from the entry bar's time (time), never with timenow: TradingView recalculates timenow when the alert is restarted or edited, and the position gets a new identifier. If that happens, a BE or CLOSE still reaches the latest position the strategy opened on that symbol, as long as the strategy has not closed it itself. An SL does not, nor does the BE or CLOSE of a refused opening: it never touches another position. The strategy form shows an example, under positionId. Do not reuse the ID of a position that is still open: a new BUY or SELL on that ID opens nothing. Send its CLOSE first, or use a new ID.
  • Entry and SL: required to open, a BUY or SELL without them is refused. The lot size is calculated from the distance between entry and SL. An SL must carry the new stop.
  • Prices: with a dot as decimal separator and no thousands separator, for example 1.08345 or 4012.5. 1,08345 or 4 012.50 is refused.
  • Optional TP: leave the last slot empty, for example TOKEN:1706789012345;US100;BUY;18250.5;18200. The position then opens without a take profit.
  • TradingView and broker prices often differ slightly. The EA applies the SL and TP distances from its own execution price.
  • Ghost SL: add ;GSL at the end of a BUY or SELL so the SL is used to size the lot without being placed at the broker. Your script must then send CLOSE itself when the price crosses that stop. See Ghost SL.

Your script has to build this message. To adapt it, click Copy AI prompt in the strategy form and give that text to an AI along with your script.

Create the alert in TradingView

  1. Add your script to the chart and enter the token in its settings.

  2. Create an alert. Under Condition, choose your script, then Any alert() function call.

  3. In the notifications, tick Webhook URL and paste the copied URL.

  4. Leave the message as is: the script builds the text it sends.

If your script does not use alert() but passes its messages through the strategy's orders (alert_message), choose Order fills and alert() function calls instead and put this in Message: {{strategy.order.alert_message}}.

An alert keeps the script settings from the moment it was created. After changing the script or the token, create the alert again.

Test your alerts without trading

At the assistant's Test step, the test mode lasts 30 minutes: each alert received shows with its time, type, symbol and prices, and goes to no account. A refused message shows with its reason (unknown type, missing : after the token…).

The EA only trades the strategy's Traded symbols. Type them in from the Name step, or during the test: a symbol received in an alert and missing from the strategy is offered to you, and the Add XAUUSD button (for example) adds it to the strategy and enables it in your configurations that follow it. Without any symbol, the assistant does not move on to the next step. At the Plug step, plug the strategy into an account, existing or new, with a risk per trade as an amount: that amount applies to every symbol, and the test mode stops.

Outside the test mode, an alert marked Not delivered was received but reached no EA: no account follows the strategy yet, or no EA was online.

Indices and commodities (US100, US30, oil)

The alert's symbol is matched with your strategy's ignoring case and exchange: OANDA:xauusd becomes XAUUSD. The EA then looks for that symbol at your broker:

  • Forex and precious metals: it finds your broker's suffix or prefix (.s, +…).
  • Indices and oil: it also recognizes the other names of the same family, suffixes included.
  • Crypto and other CFDs: it does not guess, enter the name yourself (see below).
FamilyRecognized names
Nasdaq 100US100, NAS100, USTEC, NDX100
Dow JonesUS30, DJ30, WS30
S&P 500US500, SPX500, SP500
DAXDE40, GER40, DAX40, DE30, GER30, DAX30, DE30EUR, DE40EUR, GERMANY30, GERMANY40
FTSE 100UK100, FTSE100
CAC 40FR40, CAC40
Nikkei 225JP225, JPN225, NIKKEI225
Euro Stoxx 50EU50, STOXX50, EUSTX50
Australia 200AUS200, AU200
Hong Kong 50HK50, HSI50
Spain 35ES35, SPA35
Switzerland 20CH20, SMI20
WTI oilUSOIL, WTIUSD, XTIUSD, WTI
Brent oilUKOIL, BRENTUSD, XBRUSD, BRENT

For example, a strategy that sends US100 finds NAS100 at a broker that uses that name. Only tradable symbols are kept, with priority to those in MetaTrader's Market Watch.

If several symbols match, or none, open Dashboard, choose the account, then Account settings › Symbol mappings. Choose the exact broker symbol, or exclude the instrument.

My alert does nothing

If your alert does not show up in Signals, it was refused or it uses a symbol missing from your strategy. Check:

  • the token: regenerated, miscopied, or strategy deleted;
  • the format: the : after the token, at least positionId;SYMBOL;TYPE, a type among BUY, SELL, BE, SL, CLOSE, one signal per message, the entry and SL of an opening, prices written with a dot;
  • the symbol: it must be one of the strategy's Trading Symbols (case and exchange prefix ignored). A BUY or SELL on another symbol is refused, and the assistant offers to add it; a BE, SL or CLOSE always goes through, so an open position is never blocked;
  • the webhook URL, and that the alert is active in TradingView.

If the signal shows up but no position opens, click its row: the reason is written in the detail. See No position was opened.

The webhook's answer

If your tool reads the answer (TradingView only shows it in its alert log):

CodeMeaning
200Signal sent to your EAs. "status": "duplicate": the same signal was already sent less than a minute ago, nothing is sent again.
202Signal recorded but sent to no EA: reason says why (no subscribed EA, position already closed, ID already in use…).
400Message refused: the answer's text says what is wrong.
401Unknown or regenerated token, or deleted strategy.
502Relay unavailable: the signal was not sent. When it reconnects, the EA still receives an opening less than 2 minutes old, and a BE, SL or CLOSE less than 7 days old.
Did this article help?
Can't find the answer?Email support, or sign in to ask the help assistant.