TradingView: Custom Scripts, Alerts & Webhooks
How to use TradingView's charting platform, write custom Pine Script indicators, set up alerts, and connect webhooks to automate real trades through IntelliTrade.
What Is TradingView?
TradingView is the world's most popular charting and social trading platform. It provides real-time charts, technical analysis tools, custom scripting (Pine Script), and a social community of millions of traders.
What makes TradingView essential for modern trading:
- Browser-based — No downloads needed, works on any device with a web browser
- Real-time data — Stocks, futures, forex, crypto, and options data from global exchanges
- Pine Script — A purpose-built programming language for creating custom indicators and strategies
- Alerts — Set conditions that trigger notifications via email, app, SMS, or webhook
- Community — Thousands of free public indicators and scripts shared by other traders
Charting and Technical Analysis
TradingView's charting engine is its core strength. You can analyze any instrument with dozens of chart types and hundreds of built-in indicators.
Key Chart Features
Chart Types
Candlestick, Heikin Ashi, Renko, Range, Line, Area, and more. Most traders use candlestick charts for their rich price action information (open, high, low, close).
Timeframes
From 1-second to monthly charts. Futures traders typically use 1-min, 5-min, and 15-min for intraday. Swing traders use daily and weekly. You can view multiple timeframes simultaneously.
Drawing Tools
Trend lines, Fibonacci retracements, horizontal levels, channels, rectangles, and pitchforks. These help identify support, resistance, and price patterns visually.
Built-in Indicators
200+ indicators: Moving Averages (SMA, EMA), RSI, MACD, Bollinger Bands, VWAP, Volume Profile, ATR, and more. Apply multiple indicators to any chart.
Popular Indicators for Futures Traders
| Indicator | Purpose | Typical Use |
|---|---|---|
| VWAP | Volume-weighted average price | Intraday fair value; price above VWAP = bullish bias |
| EMA 9/21 | Short-term trend direction | EMA crossover signals momentum shifts |
| ATR | Average True Range (volatility) | Set stop-loss distances and position sizes |
| Volume Profile | Price levels with most trading volume | Identify support/resistance at high-volume nodes |
| RSI | Relative Strength Index (momentum) | Overbought (>70) or oversold (<30) conditions |
Pine Script: Custom Indicators
Pine Script is TradingView's built-in scripting language. It lets you create custom indicators, strategies, and alerts that go far beyond the built-in tools.
What Can You Build?
- Custom indicators — Plot your own calculations, signals, and overlays on charts
- Strategy scripts — Backtest trading ideas with historical data (entries, exits, P/L)
- Alert conditions — Define complex conditions that trigger alerts (and webhooks)
- Visual tools — Draw zones, labels, tables, and annotations on charts programmatically
Pine Script Basics
Pine Script uses a simple, purpose-built syntax. Here's a basic example that plots an EMA crossover signal:
//@version=5
indicator("EMA Crossover Signal", overlay=true)
// Define two EMAs
fast = ta.ema(close, 9)
slow = ta.ema(close, 21)
// Plot the EMAs
plot(fast, "Fast EMA", color=color.blue, linewidth=2)
plot(slow, "Slow EMA", color=color.orange, linewidth=2)
// Detect crossovers
bullCross = ta.crossover(fast, slow)
bearCross = ta.crossunder(fast, slow)
// Plot signals on chart
plotshape(bullCross, "Buy", shape.triangleup,
location.belowbar, color.green, size=size.small)
plotshape(bearCross, "Sell", shape.triangledown,
location.abovebar, color.red, size=size.small)
// Create alert conditions
alertcondition(bullCross, "EMA Bull Cross",
"EMA 9 crossed above EMA 21")
alertcondition(bearCross, "EMA Bear Cross",
"EMA 9 crossed below EMA 21")
Opening Range Breakout (ORB) in Pine Script
IntelliTrade uses a custom Pine Script for the Opening Range Breakout strategy on futures. The script calculates the first N minutes of the trading session (the "opening range") and triggers alerts when price breaks above or below that range:
//@version=5
indicator("ORB - Opening Range Breakout", overlay=true)
// Inputs
orbMinutes = input.int(3, "ORB Minutes", minval=1, maxval=30)
sessionStart = input.session("0930-0933", "ORB Session")
// Track opening range high/low
var float orbHigh = na
var float orbLow = na
inORB = not na(time(timeframe.period, sessionStart))
if inORB
orbHigh := na(orbHigh) ? high : math.max(orbHigh, high)
orbLow := na(orbLow) ? low : math.min(orbLow, low)
// Plot ORB levels
plot(orbHigh, "ORB High", color.green, style=plot.style_line)
plot(orbLow, "ORB Low", color.red, style=plot.style_line)
// Breakout detection
longBreak = ta.crossover(close, orbHigh)
shortBreak = ta.crossunder(close, orbLow)
alertcondition(longBreak, "ORB Long", "Price broke above ORB High")
alertcondition(shortBreak, "ORB Short", "Price broke below ORB Low")
Setting Up Alerts
Alerts are TradingView's notification system. They monitor your conditions 24/7 on TradingView's servers — your computer doesn't need to be on.
Types of Alert Conditions
Price Alerts
Trigger when price crosses a specific level. Example: "Alert me when ES crosses above 6050." Simple but powerful for key support/resistance levels.
Indicator Alerts
Trigger based on built-in indicator conditions. Example: "Alert when RSI crosses below 30." Works with any plotted indicator on your chart.
Custom Script Alerts
Trigger from alertcondition() in your Pine Script. Most flexible — define any logic you want. This is what powers IntelliTrade's webhook automation.
Strategy Alerts
Trigger from strategy entry/exit orders. Example: "Alert on every strategy.entry() call." Useful for backtested strategies you want to automate.
Creating an Alert
- Right-click on the chart or click the alarm clock icon
- Select the Condition (price level, indicator, or Pine Script alert)
- Configure trigger settings (once, once per bar close, every time)
- Set expiration (alerts auto-expire on free plans; paid plans can run indefinitely)
- Choose notification method: popup, email, SMS, app notification, or webhook URL
- Write the alert message (can include dynamic variables)
Webhooks: From Alert to Trade
A webhook is an HTTP request that TradingView sends to a URL when an alert fires. This is the bridge between your TradingView analysis and real trade execution.
How Webhooks Work
TradingView Alert Fires
|
v
TradingView sends HTTP POST
to your webhook URL
|
v
Your server receives the request
(IntelliTrade webhook bridge)
|
v
Parse the JSON payload
(ticker, action, quantity, etc.)
|
v
Execute the trade via broker API
(Interactive Brokers, Tradier, etc.)
|
v
Confirm and log the result
Setting Up a Webhook Alert
- Create your alert condition as normal
- In the alert dialog, check the "Webhook URL" checkbox
- Enter your webhook endpoint URL (e.g.,
https://your-server.com/webhook) - Write a JSON message in the alert body (this is the payload your server receives)
JSON Alert Payloads
The alert message body is sent as the webhook's HTTP POST body. You write this in the alert creation dialog using JSON format with TradingView's dynamic variables.
Basic Payload Structure
{
"action": "buy",
"ticker": "{{ticker}}",
"price": {{close}},
"quantity": 1,
"account": "DU12345",
"secret": "your-auth-token"
}
TradingView Dynamic Variables
| Variable | Description | Example Output |
|---|---|---|
{{ticker}} |
Symbol of the chart | MESM2026 |
{{close}} |
Current close price | 6052.25 |
{{open}} |
Current open price | 6048.50 |
{{high}} |
Current bar high | 6055.00 |
{{low}} |
Current bar low | 6047.75 |
{{volume}} |
Current bar volume | 15234 |
{{time}} |
Bar time (UTC timestamp) | 2026-02-27T14:35:00Z |
{{exchange}} |
Exchange name | CME_MINI |
{{interval}} |
Chart timeframe | 5 |
Advanced Payload Example
A complete webhook payload for an ORB breakout trade with risk management:
{
"action": "{{strategy.order.action}}",
"ticker": "{{ticker}}",
"price": {{close}},
"order_type": "limit",
"quantity": 2,
"stop_loss": {{plot("stop")}},
"take_profit": {{plot("target")}},
"strategy": "ORB_v11",
"timeframe": "{{interval}}",
"account": "DU12345",
"secret": "abc123-your-secret-token"
}
IntelliTrade + TradingView Integration
IntelliTrade's IBKR Webhook Bridge is designed to receive TradingView webhook alerts and execute trades through Interactive Brokers. This is how the futures trading system works.
Architecture
TradingView Cloud
(Pine Script + Alert)
|
| HTTPS POST (JSON)
v
IntelliTrade Webhook Bridge
(localhost:5001 or ngrok tunnel)
|
| Validates auth token
| Parses trade parameters
| Applies risk checks
v
Interactive Brokers TWS/Gateway
(IB API connection)
|
| Places order
v
Exchange (CME, CBOE, etc.)
|
| Fill confirmation
v
IntelliTrade Dashboard
(trade logged, P/L tracked)
What the Bridge Handles
- Authentication — Validates the secret token in every incoming webhook
- Order routing — Maps TradingView ticker symbols to IB contract specifications
- Risk management — Enforces position limits, daily loss limits, and account restrictions
- Bracket orders — Attaches stop-loss and take-profit orders automatically
- Fill tracking — Monitors order fills and updates the trade database
- Webhook log — Records every incoming webhook for debugging and audit
Example: Opening Range Breakout Strategy
IntelliTrade's futures module uses a TradingView-based Opening Range Breakout (ORB) strategy. Here's how all the pieces fit together:
The ORB Flow
- Market opens at 9:30 AM ET — Pine Script starts tracking the first 3 minutes of price action
- 9:33 AM: Opening range is defined (high and low of first 3 candles)
- Breakout detected: Price closes above the ORB high (bullish) or below the ORB low (bearish)
- Alert fires: TradingView sends a webhook with action, price, stop, and target
- Bridge receives: Validates the payload and places a bracket order on IB
- Order placed: Entry + stop-loss + take-profit (e.g., 2:1 reward-to-risk)
- Trailing stop: After initial profit target is partially filled, trail the remainder
ORB Alert JSON
{
"action": "buy",
"ticker": "MES",
"price": 6052.25,
"stop_loss": 6044.50,
"take_profit": 6067.75,
"quantity": 2,
"strategy": "ORB_v11",
"risk_pts": 7.75,
"reward_pts": 15.50,
"orb_high": 6052.00,
"orb_low": 6044.50,
"secret": "your-token"
}
Risk Parameters
| Parameter | Value | Purpose |
|---|---|---|
| ORB window | First 3 minutes | Defines the breakout range |
| Reward:Risk | 2:1 minimum | Take profit at 2x the stop distance |
| Max daily loss | $500 | Stop trading after cumulative loss limit |
| Max contracts | 2 MES | Position size limit per trade |
| Trading window | 9:33 AM – 11:00 AM | ORB signals only valid in first 90 minutes |
| Trailing stop | After +$100 profit | Trail stop to lock in gains |
Best Practices
Pine Script Tips
- Use
barstate.isconfirmed— Only fire signals on confirmed (closed) bars to avoid false triggers from incomplete candles - Add filters — Combine your signal with volume confirmation, trend filters, or time-of-day restrictions
- Backtest first — Use
strategy()mode to test your logic on historical data before going live - Version your scripts — Always use
//@version=5and keep copies of working versions - Avoid repainting — Ensure your indicator doesn't change historical values (test with bar replay)
Webhook Tips
- Always include a secret token — Authenticate every webhook to prevent unauthorized trades
- Use "Once Per Bar Close" — Avoids multiple signals from the same candle
- Test with paper trading — Run your webhook pipeline with a paper trading account before going live
- Monitor the webhook log — IntelliTrade logs every incoming webhook at
/futures?tab=webhook-log - Set up fallback alerts — Send both webhook + email so you're notified if the webhook fails
- Use ngrok or a tunnel — For local development, use a secure tunnel to expose your webhook bridge to TradingView's servers