How to set up TradingView webhook alerts
Learn how to add a TradingView webhook URL and alert message, then test delivery. PineHook routes your alerts to MT5 or cTrader for automated trading.
Last updated: 2026-10-08
TradingView can send an alert message to a webhook URL when a price, indicator, or strategy condition fires. To set this up, create an alert, enable Webhook URL under Notifications, and enter the destination URL and the message TradingView should send.
PineHook supplies that URL and routes supported alert messages to the MT5 or cTrader account you connect, so your TradingView strategy can place orders without running your own webhook server. Create a PineHook account, connect your trading account, and test the message you intend to use on a demo account.
PineHook is independent of TradingView and is not affiliated with or endorsed by it.
Before you start#
Before creating an alert, make sure your TradingView plan supports webhooks and that you have enabled two-factor authentication. You also need a PineHook license connected to an MT5 account or cTrader account; use a demo account for your first trade. If Webhook URL does not appear in the alert dialog, check your TradingView plan and two-factor settings.
The steps below cover chart and indicator conditions. If you can't edit a strategy's code, mirror its position with setposition. If you can edit your strategy code, jump to programmatic alerts; for messages sent on strategy fills, use the order-fill walkthrough.
Set up a TradingView webhook alert#
- Open the chart for the symbol you intend to trade, then select Create alert in TradingView.
- Choose a price or indicator condition, then select a trigger frequency. The options depend on the condition you choose, and a bar-close option waits until the bar finishes.
- Under Notifications, enable Webhook URL and enter
https://relay.pinehook.io/webhook. - In Message, enter the webhook command you want your strategy to send, including your PineHook license key. The CSV and JSON messages below are format examples; choose the action, symbol, and parameters that fit your strategy:
YOUR_LICENSE_KEY,buy,{{ticker}},size_lots=0.01,sl_pips=50,tp_pips=100,id={{timenow}}-{{close}}CSV example:
YOUR_LICENSE_KEY,buy,{{ticker}},size_lots=0.01,sl_pips=50,tp_pips=100,id={{timenow}}-{{close}}JSON example:
{
"license": "YOUR_LICENSE_KEY",
"action": "buy",
"symbol": "{{ticker}}",
"size_lots": 0.01,
"sl_pips": 50,
"tp_pips": 100,
"id": "{{timenow}}-{{close}}"
}TradingView placeholders
TradingView replaces placeholders such as {{ticker}}, {{close}}, and {{timenow}} with the chart symbol, bar close price, and alert time when the alert fires. See TradingView's placeholder guide for the full list.
- Name the alert and select Create.
When the alert fires, TradingView sends its message to the webhook URL, and PineHook uses the license key in that message to find your connected account. Check that the resulting symbol matches one your broker recognizes. If the broker uses a different name, set up broker symbol mapping to translate the symbol before PineHook sends the order. This example opens a 0.01-lot buy with a 50-pip stop loss and a 100-pip take profit; for other actions or sizing options, see Signal commands.
Send webhook alerts from Pine Script#
If you can edit your strategy's Pine Script code, we recommend building the PineHook command with alert() so you control both the message and the condition that sends it. Our full Pine Script strategy alerts guide walks through the code, webhook settings, and demo test.
Give each alert an ID#
TradingView may resend a webhook after a server error. To protect against duplicate trades, PineHook normally treats a byte-for-byte repeat for the same license within a 12-second window as the same alert.
As a general rule of thumb, include id= in every command and change its value for each intended firing. This changes the alert's bytes even when the trade details stay the same, so PineHook can tell two real alerts apart; a resend keeps the original ID and is caught. Adding id= also enables duplicate protection for partial closes and some position commands that otherwise skip it. The ID only affects this check; it is not sent to your broker.
For a message typed into TradingView's alert dialog, use id={{timenow}}-{{close}} as shown above, though two alerts can still share that value if they fire in the same second at the same close price. If you edit Pine Script, generate the ID inside each alert() branch with timenow and math.random(), as in the example. This gives each firing a new random component; generating one ID at the top of the script can reuse it across alerts.
Test your setup#
Start by pasting your message into the alert format validator on Dashboard > Signal Logs. MT5 users can also select Test EA Connection there to check the EA without placing a trade; if you use cTrader, check the license's account status under Licenses and confirm the assigned account in Dashboard > Settings > Platform connections.
To check the entire route, create a TradingView alert for a symbol on your demo account and choose a price condition you can observe. Use that symbol in the message, or use {{ticker}}, and include any stop loss or take profit fields your strategy requires. Then let the condition occur; the timing depends on the condition and trigger frequency you chose.
- In TradingView's Alerts > Log, confirm the alert fired and inspect any webhook error.
- In PineHook Signal Logs, find the message and check whether PineHook accepted or rejected it.
- In MT5, review the Experts log and Trade tab; in cTrader, check the assigned broker account and its orders or positions. Compare the symbol, volume, stop loss, and take profit with the message you sent.
If the alert never fires, check its condition, status, and expiry in TradingView. When TradingView reports a webhook error, confirm the URL and your eligibility to use webhooks. If PineHook has no matching log, review the license key and message format; if PineHook rejected the signal, its log gives the reason. When PineHook accepts the signal but no order appears, check the platform connection, broker symbol, market hours, margin, and account trading settings. The Signals not received guide walks through these checks in more detail.
Change or pause an alert#
TradingView's Alerts panel lets you pause, resume, or delete an alert, and you can edit a chart alert's condition or message there as well. Pine Script alerts need a different approach because TradingView saves a snapshot when you create one: after changing the script, its inputs, the symbol, or the timeframe, delete the old alert and create a new one from the updated chart. Before relying on it, check the new alert's webhook URL and message.