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.
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
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.
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,SLandCLOSEmust reuse exactly the one of itsBUYorSELL. Build it from the entry bar's time (time), never withtimenow: TradingView recalculatestimenowwhen the alert is restarted or edited, and the position gets a new identifier. If that happens, aBEorCLOSEstill reaches the latest position the strategy opened on that symbol, as long as the strategy has not closed it itself. AnSLdoes not, nor does theBEorCLOSEof 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 newBUYorSELLon that ID opens nothing. Send itsCLOSEfirst, or use a new ID. - Entry and SL: required to open, a
BUYorSELLwithout them is refused. The lot size is calculated from the distance between entry and SL. AnSLmust carry the new stop. - Prices: with a dot as decimal separator and no thousands separator, for example
1.08345or4012.5.1,08345or4 012.50is 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
;GSLat the end of aBUYorSELLso the SL is used to size the lot without being placed at the broker. Your script must then sendCLOSEitself 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
Add your script to the chart and enter the token in its settings.
Create an alert. Under Condition, choose your script, then Any alert() function call.
In the notifications, tick Webhook URL and paste the copied URL.
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).
| Family | Recognized names |
|---|---|
| Nasdaq 100 | US100, NAS100, USTEC, NDX100 |
| Dow Jones | US30, DJ30, WS30 |
| S&P 500 | US500, SPX500, SP500 |
| DAX | DE40, GER40, DAX40, DE30, GER30, DAX30, DE30EUR, DE40EUR, GERMANY30, GERMANY40 |
| FTSE 100 | UK100, FTSE100 |
| CAC 40 | FR40, CAC40 |
| Nikkei 225 | JP225, JPN225, NIKKEI225 |
| Euro Stoxx 50 | EU50, STOXX50, EUSTX50 |
| Australia 200 | AUS200, AU200 |
| Hong Kong 50 | HK50, HSI50 |
| Spain 35 | ES35, SPA35 |
| Switzerland 20 | CH20, SMI20 |
| WTI oil | USOIL, WTIUSD, XTIUSD, WTI |
| Brent oil | UKOIL, 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 leastpositionId;SYMBOL;TYPE, a type amongBUY,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
BUYorSELLon another symbol is refused, and the assistant offers to add it; aBE,SLorCLOSEalways 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):
| Code | Meaning |
|---|---|
| 200 | Signal sent to your EAs. "status": "duplicate": the same signal was already sent less than a minute ago, nothing is sent again. |
| 202 | Signal recorded but sent to no EA: reason says why (no subscribed EA, position already closed, ID already in use…). |
| 400 | Message refused: the answer's text says what is wrong. |
| 401 | Unknown or regenerated token, or deleted strategy. |
| 502 | Relay 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. |