Automating TradingView Alerts with Webhooks
What a webhook is, indicator vs strategy alerts, building a JSON message with placeholders, and what to check so your alert automation stays reliable and secure.
TradingView is one of the most popular tools for charting and building strategies, but its alerts do not send orders to a broker on their own. The bridge between an alert and an execution is a webhook: an automatic message sent to an address you choose the moment the alert fires. This article explains how that works, what to put in the message, and which reliability and security traps are worth knowing in advance.
What a webhook is
A webhook is a mechanism in which one system sends an HTTP request to another when something happens, instead of the second system constantly asking "anything new?". With TradingView, when an alert condition is met, TradingView's servers send a POST request to the webhook URL you configured, and the request body contains the text you wrote in the message field.
The receiving side, such as an automation platform, reads the message, works out what to do (buy, sell, close, quantity) and sends the order to the broker account. Keep in mind: TradingView only sends the message. All decisions about execution, risk management and sanity checks happen on the receiving side.
According to TradingView's help center, webhook delivery depends on your subscription plan and usually requires two-factor authentication on the account. Requirements can change, so check the current details on their official site.
Indicator alerts vs strategy alerts
There are two main kinds of alerts used for automation:
- Indicator or condition alert: created on an indicator, on price, or on an alert function in Pine code. A good fit when the logic is simple, or when the indicator itself decides when to send a signal.
- Strategy alert: created on a strategy-type script and fired when the strategy engine executes a simulated order (entry, exit, reversal). The advantage is that the message can carry information about the order itself, such as direction and size.
The difference matters because it changes behavior. A strategy alert depends on the strategy settings, for example whether it calculates only on bar close or on every tick. If your backtest ran on bar close and the live alert runs intrabar, results can differ. Check the settings and make sure they are consistent.
Building the message: JSON and placeholders
Most automation systems expect a message in JSON format, a structure of fields and values. In words, a typical message contains fields such as which symbol to trade, which direction, how many contracts, and sometimes a strategy ID or an identifying token for the connection. The exact format is defined by the receiving side, so always copy the template from the documentation of the platform you use.
TradingView supports placeholders: variables inside double curly braces that are replaced with real values at send time. There are placeholders for the symbol, the close price, the time, and in strategy alerts also for order direction and quantity. Using placeholders correctly lets you reuse the same message template across several charts without rewriting it.
A few rules worth keeping:
- Keep the JSON valid: double quotes around field names and text, commas between fields, no trailing comma at the end.
- Do not rely on fields that may not be filled in every situation.
- Check the substituted message in TradingView's alert log to see what was actually sent.
The right symbol and contract rollover
Futures add a unique problem: the continuous chart (for example NQ1!) shows the front contract and switches automatically, but the broker needs to know which specific contract to trade. If the message sends the continuous chart's name, the receiving side has to translate it to the right contract. If it sends a specific contract, the alert must be updated when it is time to roll. The full explanation is in the article on futures contract rollover.
Reliability considerations
Good automation is automation where you know when it did not work. Points to be aware of:
- Alert expiration: on some plans alerts have an expiration date. An expired alert simply stops sending, silently. Set yourself a reminder.
- Script changes: if you edit the indicator or strategy, the existing alert may keep running on the old version. Usually you need to recreate it.
- Duplicate alerts: two alerts on the same chart, or an alert that fires more than once per bar, can send a duplicate order. Set the trigger frequency deliberately, and ideally let the receiving side detect duplicates.
- Delays: a webhook travels over the internet and can be delayed. In a fast market a small delay affects price; see the article on slippage and execution costs.
- Receiver failure: if the receiving server is unavailable, the message may be lost. A good system will alert you.
Securing your webhook URL
Your webhook URL is effectively a key: anyone who knows it, and knows the message format, can send orders to your account. Therefore:
- Do not publish the URL in screenshots, forums or chat groups.
- Where possible, use a secret token inside the message that the receiving side verifies.
- If you suspect the URL has leaked, create a new connection and revoke the old one.
- Set risk limits on the receiving side, so that even a malformed message cannot open a huge position.
Pre-launch checklist
- Was the strategy tested with the same calculation settings the alert runs on?
- Is the message valid JSON according to the receiver's documentation?
- Is the symbol mapped to the correct contract?
- Do you know the alert's expiration date?
- Have you set a daily loss limit and a maximum number of contracts?
- Did you test everything in simulation first?
Key takeaways
- A webhook is just a messenger: TradingView sends a message, and the receiving side executes and manages risk.
- Strategy alerts can pass direction and quantity, but need consistent calculation settings.
- Valid JSON and correct placeholders prevent a lot of mistakes.
- Expiration, duplicates and script edits are common failure sources.
- Your webhook URL is a secret; treat it like a password.
If you want to see what this looks like in practice, there is a guide on connecting TradingView alerts to WeCore. WeCore receives the alerts, turns them into orders on your broker or prop-firm account and applies automated risk limits, and you can start in simulation mode.