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:
- Price alerts — Fire when price crosses above or below a level. Simplest type. Good for basic triggers, useless for strategy-level automation.
- Indicator alerts — Fire when an indicator crosses a threshold (e.g., RSI > 70). Useful but limited — the alert condition is tied to the indicator's output, not a compound signal.
- Pine Script alerts — Created from within a Pine Script using
alert()oralertfrequency. These are the most powerful because you define exactly what conditions trigger them in code. This is what TrendFlow uses. (If you are new to Pine Script, start with our Pine Script tutorial — it covers the language basics before you dive into alert code.) - Drawings alerts — Fire when price crosses a horizontal line or trendline you drew manually. Good for manual strategy monitoring, bad for automated systems.
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:
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.).
//@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.
// — 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.
{
"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:
- Exchange rate limits — Binance limits you to 1200 orders per minute. If you have 5 symbols running 4H strategies, each generating 2-3 signals per day, you are fine. If you scale to 1-minute strategies, you will hit the rate limit.
- Partial fills — Market orders on volatile crypto can fill at multiple prices. Your system needs to track the actual fill price, not the estimated entry.
- Order idempotency — If TradingView fires the same alert twice (it happens), your system must recognize the duplicate and not double your position. The entry/exit logic in that pipeline is typically a crossover strategy — see how TrendFlow's EMA crossover strategy defines signal rules.
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:
- 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.
- 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.
- 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.
- 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.
- Manual override switch — Always be able to disable automation instantly. A big market event is not the time to debug your code.
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:
- 5 proprietary scripts — multi-factor confirmation filters that reduce false signals vs. a raw EMA crossover. Our EMA Crossover Strategy guide explains the base logic that these scripts refine. Scripts run 24/7 across BTC, ETH, SOL, and other pairs.
- Webhook infrastructure — TradingView alerts are wired to TrendFlow's signal pipeline. No building required on your end.
- Signal delivery — LONG/SHORT signals with entry, stop-loss, and target are delivered to your inbox every morning, plus real-time alerts for high-conviction signals on Pro and Premium plans.
- Safety flags — signals are evaluated against daily drawdown thresholds before delivery. If market conditions are extreme, signals are flagged accordingly.
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 →