The Four Types of TradingView Alerts

Before automating anything, you need to understand what TradingView can actually trigger. There are four alert types, and most beginners only use one:

The key insight: Pine Script alerts are the only alert type where the trigger condition is fully programmatic. You can write code that says "fire when EMA9 crosses EMA21 AND RSI(14) > 55 AND volume > 1.2× the 20-bar average." No other alert type supports compound conditions.

How Webhooks Turn Alerts into Actions

A webhook is an HTTP POST request that TradingView sends to a URL you specify when an alert fires. The URL is your server endpoint — it receives the request, validates it, and executes whatever action you have configured (place an order, send a notification, log a signal).

The full pipeline looks like this:

1
Pine Script detects signal condition
EMA cross fires in real time on the TradingView chart
2
TradingView fires alert
Alert triggers, sends POST to your webhook URL with signal payload
3
Your endpoint receives and validates
Server checks payload, rate limits, balances, and safety flags
4
Order sent to exchange
Market or limit order placed on Binance, Coinbase, etc.
5
Signal logged and reported
Confirmation sent to you via email or Slack

Each step has a failure mode. TradingView may fire duplicate alerts if your internet connection stutters. Your server may receive malformed payloads. The exchange API may throttle you. A robust automation system handles all of these. TrendFlow's signal pipeline accounts for all five failure modes — including deduplication, rate limiting, and automatic retry.

Writing Pine Script Alerts That Fire Reliably

The alert() function in Pine Script tells the indicator when to fire an alert. It does not create the alert — TradingView's alert dialog does that. The alert() call inside your script defines the condition, and the alert dialog configures the delivery mechanism (webhook URL, message, etc.).

Pine Script v5 — Alert setup
//@version=5
indicator("Alert EMA Cross", overlay=true)

fastLen = input.int(9,  title="Fast EMA")
slowLen = input.int(21, title="Slow EMA")

fastEma = ta.ema(close, fastLen)
slowEma = ta.ema(close, slowLen)

// — Detect crossover (fires once per bar, not continuously)
bullCross = ta.crossover(fastEma, slowEma)
bearCross = ta.crossunder(fastEma, slowEma)

// — Trigger alert when crossover condition is true
alertcondition(bullCross, title="Bull EMA Cross",
     message="{{ticker}}: Fast EMA crossed above Slow EMA — LONG signal")
alertcondition(bearCross, title="Bear EMA Cross",
     message="{{ticker}}: Fast EMA crossed below Slow EMA — SHORT signal")

// — Plot (visual confirmation)
plot(fastEma, color=color.orange, linewidth=2)
plot(slowEma, color=color.blue, linewidth=2)
plotshape(bullCross, title="LONG", style=shape.labelup,
     location=location.belowbar, color=color.lime, textcolor=color.black)
plotshape(bearCross, title="SHORT", style=shape.labeldown,
     location=location.abovebar, color=color.red, textcolor=color.white)

Critical Pine Script alert gotcha: alertcondition() fires once per bar, not continuously when the condition is true. If you are on a 1-hour chart, the alert can only fire at the bar close — not mid-bar when the cross happens. For faster alerts on lower timeframes, use the "Once Per Bar" setting in the alert dialog (less frequent) or switch to a lower timeframe chart.

There is also an alert() function (different from alertcondition()) that fires every tick where its condition is true, giving you sub-bar alert timing. Use it carefully — on high-frequency charts it can generate a flood of alerts.

Pine Script v5 — Per-tick alert (advanced)
// — Fires on every tick where condition is true (sub-bar precision)
if bullCross
    alert("{{ticker}} LONG at {{close}} on {{interval}} TF",
         alert.freq_once_per_bar_close)

Auto-Trading Pipeline: From Signal to Order

A webhook alert fires. Your server receives it. What happens next?

Your endpoint receives a JSON payload from TradingView containing at minimum: the alert name, the ticker, the current price, and the bar time. You can customize this with {{strategy.order.alert}} message in the alert dialog to include entry price, stop-loss, and any other context your server needs to place the order.

Example Webhook Payload
{
  "symbol": "BTCUSDT",
  "side": "LONG",
  "entry": 67412.50,
  "stop": 66100.00,
  "target": 69800.00,
  "strategy": "EMA Cross v2",
  "tf": "4h",
  "ts": "2026-06-27T08:00:00Z"
}

Your server parses this, checks that the position size is within your risk limits, verifies you have sufficient balance, places the order with your exchange's API, and logs the result. If the order fills, you send a confirmation via email or Slack.

This sounds simple but has real complexity:

Safety Checks You Must Have

Automated trading without safety rails is a recipe for catastrophic losses. These are non-negotiable if you are connecting a webhook to real money:

  1. Position size hard cap — Never allow a single order to exceed X% of your account (1-2% is standard). Check this before sending the order, not after.
  2. Daily trade limit — Cap maximum trades per day. If the strategy fires 20 signals in a volatile market, your account should survive a worst-case scenario where all 20 are wrong.
  3. Maximum drawdown stop — If your account is down 5% in a single day, pause all automated trading. This is the most common mistake in auto-trading — letting a losing streak run without intervention.
  4. Connection health check — Your server should ping your exchange API every 60 seconds. If the ping fails 3 times in a row, pause auto-trading and send you an alert.
  5. Manual override switch — Always be able to disable automation instantly. A big market event is not the time to debug your code.
⚠ Warning

Auto-trading with real money involves significant risk. A script bug, exchange API change, or network failure can cause losses faster than you can react. Test on paper (simulated orders with zero balance) for at least 2-4 weeks before connecting to a funded account. TrendFlow's automated pipeline includes all five safety checks above — and requires you to complete paper trading validation before enabling live execution.

How TrendFlow Handles All of This

TrendFlow was built specifically to solve the automation problem: you get the Pine Script signals, the alert infrastructure, and the delivery mechanism without needing to build any of it yourself. Here is what the system handles:

You do not need to automate execution to use TrendFlow. Many subscribers use the email signals as a morning research tool — they review the signals, decide which ones to act on, and execute manually. This is a perfectly valid approach, especially if you are early in your trading development. The automation layer is there when you are ready for it.

If you want to get started with TrendFlow's signals, see the signal plans. Free plan gives you access to the charts and basic signals. Pro ($15/mo) adds real-time alerts and additional pairs. Premium ($29/mo) adds all pairs, maximum signal frequency, and priority delivery.

Continue reading: write your first Pine Script alert indicator or build an EMA crossover strategy with ATR filtering.

Stop building the infrastructure. Start trading the signals.

TrendFlow handles the Pine Scripts, the alert pipeline, and the signal delivery. You focus on managing your positions.

See Signal Plans →