TradeLabs AILearn

Alerts and Webhooks

How price alerts and webhooks work, how to send TradingView alerts to your own server or a chat channel, and how to secure webhook endpoints against fake signals.

Intermediate3 min readUpdated 3 Oct 2026
Markdown
Lesson 11 of 27

An alert tells you that something happened: price crossed a level, an indicator triggered or your bot hit an error. A webhook is a way for one system to send that message to another automatically, as an HTTP request to a URL. Together, alerts and webhooks let traders connect charting platforms, bots, servers and chat apps without writing a full trading system. They are the glue behind many semi automated setups, and also the basis of the monitoring that keeps fully automated systems safe.

Types of trading alerts#

AlertExampleLesson
PriceBTC crosses $100,000Support and Resistance
IndicatorRSI drops below 30RSI (Relative Strength Index)
Strategy signalMoving average crossoverPine Script Basics
AccountMargin usage above 50%Margin
System healthBot has not sent a heartbeat in 2 minutesMonitoring Positions, P&L and Risk
RiskDaily loss limit reachedMaximum Trade Risk and Daily Loss Limits

How a webhook works#

  1. You give a service, such as TradingView, a URL that belongs to your server or another app.
  2. When the alert fires, the service sends an HTTP POST request to that URL with a message body, usually JSON.
  3. Your server receives the message, checks it and acts: logs it, sends a notification or passes it to a bot.

A TradingView alert message#

TradingView lets you write the alert message, with placeholders that fill in live values:

{
  "secret": "replace-with-a-long-random-value",
  "strategy": "sma-cross",
  "ticker": "{{ticker}}",
  "action": "{{strategy.order.action}}",
  "price": "{{close}}",
  "time": "{{timenow}}"
}

TradingView webhooks require a paid plan and send requests to the URL you enter in the alert settings. See TradingView.

A minimal receiver#

from flask import Flask, request, abort
import hmac, os

app = Flask(__name__)
SECRET = os.environ["WEBHOOK_SECRET"]

@app.post("/hook")
def hook():
    data = request.get_json(silent=True) or {}
    if not hmac.compare_digest(str(data.get("secret", "")), SECRET):
        abort(403)
    handle_signal(data)     # validate fields, check risk, then act
    return "ok"

Securing webhook endpoints#

Anyone who learns your webhook URL can send it messages. If those messages place trades, that is a serious risk.

  • Use HTTPS so messages cannot be read in transit.
  • Include a secret in the message or header and reject anything without it.
  • Validate every field: known symbols, allowed actions, sensible sizes.
  • Reject stale messages using the timestamp, and ignore duplicates.
  • Never let a webhook bypass risk checks. See Risk Controls and Kill Switches.
  • Keep the secret out of code and screenshots, and rotate it if exposed.

Sending alerts to chat#

Many traders route alerts to a phone through messaging apps. Discord, Slack and Telegram all accept messages from programs, either through incoming webhooks or bot APIs. This is a simple way to get bot health and trade notifications on your phone. Keep chat webhook URLs private, since anyone with the URL can post to the channel.

Avoiding alert overload#

Too many alerts lead to ignoring them. Keep alerts actionable, group related ones and review which alerts you actually act on. See Monitoring Positions, P&L and Risk.

Frequently asked questions#

What is a webhook in trading?#

An automatic HTTP message sent from one system to another when an event happens, such as a TradingView alert sending a signal to a trading bot.

Can TradingView alerts place trades automatically?#

They can send webhooks to services or your own server that place trades; TradingView itself does not place trades through webhooks.

How do I secure a trading webhook?#

Use HTTPS, require a secret, validate every field, reject stale or duplicate messages and keep risk checks in place.

Next, learn the institutional standard for order messaging in FIX Protocol.

Check your understanding

3 quick questions on this lesson. Get them all right to finish it.

Turn on JavaScript to take the quiz.

Finished this lesson?Sign in to save your progress across devices.
Next lessonFIX ProtocolFIX is the standard messaging protocol for institutional trading. Learn how FIX sessions, messages and tags work, a sample order message and when traders use FIX.

Mentioned in