An alert usually tells you something. A webhook lets it tell another program instead. By the end of this lesson, you'll know what a webhook is and how a TradingView alert sends one. You'll also know what the message inside looks like, and the ways it can fail to arrive.
1 of 10
What you'll learn
- Tell an alert from a webhook. An alert tells you. A webhook tells a program.
- Set one up in TradingView. Tick Webhook URL in the alert and add the address.
- Write the message. It's often JSON text. Placeholders get swapped for real values.
- Check the alert log. A webhook can arrive late, twice or not at all.
- Protect your logins. Never put a password or login in a webhook message.
Exercise
- Write down the four links a A message one program sends to another program’s web address the moment something happens, such as an alert going off.More in the glossary passes through: the platform, the internet, the receiving program and the A firm that holds your trading account, passes your orders to the market and reports your trades back.More in the glossary.
- Next to each, write one way it could fail, and how you would find out.
Quick check
1. What does a webhook do?
2. According to TradingView’s help, where can you see whether a webhook reached its address?
3. Which of these should never go in a webhook message?
0 of 3 answered.
Finished this lesson?
Tick it off and keep your place
Read the full notes
A webhook is a message a platform sends to another program's web address when an alert goes off; on TradingView you tick Webhook URL in the alert, write the message (often as JSON with placeholders), and check the log, because a webhook can arrive late or not at all.
- A A message your platform sends when the price reaches a level you set. It doesn’t place or change any order.More in the glossary tells you (Alerts). A A message one program sends to another program’s web address the moment something happens, such as an alert going off.More in the glossary sends the same moment to a program's web address. That program decides what to do: write it down, message you, or place an order through a A firm that holds your trading account, passes your orders to the market and reports your trades back.More in the glossary's Short for application programming interface: a door into a system built for software. A bot uses a broker’s API to get prices and place orders.More in the glossary.
- On TradingView (a simplified drawing; the layout changes, and other platforms exist): open the alert box, pick the condition (for a strategy, its order fills), write the Message, tick Webhook URL and add the address, then Create. TradingView's help says webhooks need Signing in with a password plus a second check, such as a code from an app, so a stolen password alone isn’t enough.More in the glossary, and not every plan includes them.
- The message is often A plain-text way of writing labelled information that programs can read, where each value has a name, such as action set to buy and contracts set to 1.More in the glossary. Placeholders, written as a name inside double curly brackets (such as the ticker or the close), are swapped for real values when the alert goes off.
- What can go wrong (from TradingView's help): a webhook may occasionally fail to arrive (check the webhook status column in the alert log); a request is cancelled if the receiving server takes longer than three seconds. A repeated message can mean a repeated order if the receiver doesn't check its What you hold between opening a trade and closing it: how many contracts or shares, and whether you bought or sold first.More in the glossary. Never put passwords or logins in the message.
- Made-up timing: alert 10:05:00.000, received 10:05:00.600, order at the broker 10:05:00.950: 950 ms before any fill. See Delay and speed and Latency in trading.
- Answer to the drill: 1,250 ms. Guide: TradingView alerts and webhooks.
Worked example
Made-up numbersTiming one webhook
Made-up times
- Alert goes off: 10:05:00.000.
- Program receives it: 10:05:00.600.
- Order reaches the broker: 10:05:00.950.
950 ms pass before the exchange has filled anything.
Your turn
DrillMade-up times · alert 14:30:00.000 · message received 14:30:00.800 · order at the broker 14:30:01.250
Trading is risky. You can lose money, and automated trading can lose like any other trading. This lesson explains how things work. It isn’t advice.