Pine Script Trading Alerts: Complete 2026 Guide for TradingView
Pine Script trading alerts are notifications triggered by custom logic in TradingView indicators. Pine Script provides two alert mechanisms: the modern alert() function for dynamic messages, and the legacy alertcondition() for static boolean triggers.
Two Pine Script Alert Functions
| Function | Version | Best For |
|---|---|---|
alert() | v4+ | Dynamic messages with real-time variables |
alertcondition() | v3+ (legacy) | Static text alerts |
The alert() Function
//@version=6
indicator("Custom Alert", overlay=true)
rsi = ta.rsi(close, 14)
if rsi < 30
msg = "BUY @ " + str.tostring(close)
alert(msg, alert.freq_once_per_bar_close)
How to Avoid Repainting Alerts
- Use
alert.freq_once_per_bar_close - Wrap logic in
if barstate.isconfirmed - Avoid
lookahead.on - Test history vs real-time behavior โ they should match
Webhook Integration
- Build alert message as JSON or HTML in Pine Script
- Click โฐ โ Create Alert in TradingView
- Set Condition to "Any alert() function call"
- Enable Notifications โ Webhook URL
- Paste your endpoint URL
Pine Script Alert Limits by Plan
| Plan | Active Alerts | Webhooks |
|---|---|---|
| Free / Basic | 1 | โ No |
| Essential | 20 | โ No |
| Plus | 100 | โ No |
| Premium | 400 | โ Yes |
| Pro+ | 800 | โ Yes |
Common Patterns
Pattern 1: Multi-filter signal (Gold Scalpers style)
signal = isOversold and isVolumeSpike and isRangeFilter and twoGreens
if signal
msg = '{"action":"buy","entry":' + str.tostring(close) + '}'
alert(msg, alert.freq_once_per_bar_close)
Pattern 2: HTML formatting (Telegram)
msg = "๐ฏ <b>BUY SIGNAL</b>\n๐ Entry: <code>" + str.tostring(close) + "</code>" alert(msg, alert.freq_once_per_bar_close)
See Pine Script Alerts in Action
Gold Scalpers uses production-grade alert() patterns with no repainting.