TradingView is the world's most popular charting platform, used by millions of traders for technical analysis. With webhooks, you can automatically execute your TradingView alerts on MT4, MT5, cTrader, and other platforms.
What is a TradingView Webhook?
A webhook is a way for TradingView to send data to an external service when an alert triggers. Instead of just getting a notification, the webhook can execute trades automatically.
How It Works
- You create an alert in TradingView (from indicator or Pine Script)
- When the alert triggers, TradingView sends a JSON message to a webhook URL
- The webhook receiver (Social Trade Hub) parses the signal
- The trade is executed on your connected broker account
Benefits of TradingView Webhooks
- Automate any strategy: If you can code it in Pine Script, you can automate it
- No EA required: Don't need MetaTrader EAs - just TradingView alerts
- Multi-platform: Execute on MT4, MT5, cTrader, or crypto exchanges
- Cloud-based: Works 24/7 without VPS or keeping TradingView open
Setting Up TradingView Webhooks with Social Trade Hub
Step 1: Get Your Webhook URL
In Social Trade Hub dashboard:
- Go to TradingView section
- Copy your unique webhook URL
- Keep this URL private - anyone with it can send trades
Step 2: Create Your TradingView Alert
In TradingView:
- Right-click on chart → Add Alert (or press Alt+A)
- Set your condition (indicator signal, price level, etc.)
- In 'Notifications' tab, enable 'Webhook URL'
- Paste your Social Trade Hub webhook URL
- Configure the alert message (see format below)
Step 3: Configure Alert Message Format
Social Trade Hub accepts JSON-formatted alert messages:
{
"action": "buy",
"symbol": "{{ticker}}",
"ticket": "{{strategy.order.id}}",
"price": {{close}},
"sl": {{plot("SL")}},
"tp": {{plot("TP")}}
}Supported Actions
| Action | Description |
|---|---|
| buy | Open a buy/long market order |
| sell | Open a sell/short market order |
| buy_limit | Place a buy limit pending order |
| sell_limit | Place a sell limit pending order |
| buy_stop | Place a buy stop pending order |
| sell_stop | Place a sell stop pending order |
| close | Close a position by ticket |
| partial_close | Partially close a position |
| modify | Modify SL/TP of existing position |
Required Fields
- action: The type of order (see table above)
- ticket: Unique identifier for the position
- symbol: Trading symbol (for open orders)
Optional Fields
- price: Entry price (for limit/stop orders)
- sl: Stop loss price
- tp: Take profit price (or tp1, tp2, tp3 for multiple)
- lots: Position size (overrides account default)
- percent: Percentage to close (for partial_close)
Pine Script Integration
Example Pine Script strategy with webhook-ready alerts:
// Entry signal
if buyCondition
strategy.entry("Long", strategy.long)
alert('{"action":"buy","symbol":"'+syminfo.ticker+'","ticket":"'+str.tostring(strategy.opentrades)+'"}', alert.freq_once_per_bar)
// Exit signal
if sellCondition
strategy.close("Long")
alert('{"action":"close","symbol":"'+syminfo.ticker+'","ticket":"'+str.tostring(strategy.opentrades)+'"}', alert.freq_once_per_bar)
TradingView Variables
Use these placeholders in your alert messages:
- {{ticker}}: Symbol name (EURUSD, BTCUSD, etc.)
- {{close}}: Current close price
- {{open}}, {{high}}, {{low}}: Candle prices
- {{time}}: Alert timestamp
- {{strategy.order.id}}: Strategy order ID
- {{plot("Name")}}: Value of a named plot
Example Alert Messages
Simple Market Buy
{
"action": "buy",
"symbol": "EURUSD",
"ticket": "tv_001"
}Buy with SL and TP
{
"action": "buy",
"symbol": "XAUUSD",
"ticket": "gold_long_001",
"sl": 1950.00,
"tp": 1980.00
}Limit Order
{
"action": "buy_limit",
"symbol": "GBPUSD",
"ticket": "gbp_limit_001",
"price": 1.2650,
"sl": 1.2600,
"tp": 1.2750
}Close Position
{
"action": "close",
"ticket": "tv_001"
}Partial Close (50%)
{
"action": "partial_close",
"ticket": "tv_001",
"percent": 50
}Symbol Mapping
TradingView symbols may differ from your broker. Configure mapping in Social Trade Hub:
- BTCUSD → BTCUSDT (for crypto)
- XAUUSD → GOLD (for some brokers)
- US30 → DJ30 or US30.cash
Troubleshooting
Alert Not Triggering Trades
- Verify webhook URL is correct
- Check JSON format is valid
- Ensure symbol exists on your broker
- Verify account has sufficient margin
Wrong Symbol
- Configure symbol mapping in dashboard
- Check broker's exact symbol naming
Delayed Execution
- TradingView webhooks have slight delay (1-3 seconds)
- For time-critical strategies, consider direct API integration
TradingView Plan Requirements
Webhooks require TradingView Pro, Pro+, or Premium subscription. The free plan does not support webhooks.
Conclusion
TradingView webhooks open up powerful automation possibilities. Combined with Social Trade Hub, you can execute your Pine Script strategies on any supported broker - MT4, MT5, cTrader, or crypto exchanges - without needing a VPS or keeping TradingView open.
