Pine Script

Pine Script Trading Alerts: Complete 2026 Guide for TradingView

📅 May 9, 2026⏱ 8 min read

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

FunctionVersionBest 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

  1. Use alert.freq_once_per_bar_close
  2. Wrap logic in if barstate.isconfirmed
  3. Avoid lookahead.on
  4. Test history vs real-time behavior – they should match

Webhook Integration

  1. Build alert message as JSON or HTML in Pine Script
  2. Click ⏰ → Create Alert in TradingView
  3. Set Condition to "Any alert() function call"
  4. Enable Notifications → Webhook URL
  5. Paste your endpoint URL

Pine Script Alert Limits by Plan

PlanActive AlertsWebhooks
Free / Basic1❌ No
Essential20❌ No
Plus100❌ No
Premium400✅ 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.

Get Lifetime – $120