What Are TradingView Webhooks?
TradingView webhooks are HTTP POST requests that TradingView sends to a URL you specify when an alert is triggered. This allows you to connect your TradingView strategies to external services for automated trading execution.
When your strategy generates a buy or sell signal, TradingView can instantly notify your automation platform, which then executes the trade on your broker.
Why Use Webhooks for Trading Automation?
24/7 Trading: Your strategy executes automatically even when you're sleeping, working, or away from your computer.
Emotional Control: The automation follows your rules exactly - no second-guessing or emotional decisions.
Speed: Webhook execution is measured in milliseconds, much faster than manual trading.
Scalability: Execute the same alert across multiple accounts simultaneously.
TradingView Webhook Requirements
To use webhooks, you need:
- TradingView Pro, Pro+, or Premium subscription - The free plan doesn't support webhooks
- 2-Factor Authentication enabled - Required by TradingView for webhook security
- A webhook receiver URL - This is where TradingView sends alerts (like RoboQuant)
Setting Up Your First Webhook Alert
Step 1: Create Your Alert
- Open your TradingView chart
- Right-click on the chart or use the Alert button
- Set your alert condition (price level, indicator crossing, strategy order)
Step 2: Configure the Webhook
- In the alert dialog, expand "Notifications"
- Check "Webhook URL"
- Paste your webhook endpoint URL
- In the "Message" field, add your JSON payload
Step 3: JSON Message Format
Here's the basic format for trading automation:
{
"symbol": "{{ticker}}",
"side": "{{strategy.order.action}}",
"quantity": {{strategy.order.contracts}}
}
TradingView Alert Variables
TradingView provides built-in variables you can use in your webhook messages:
| Variable | Description | Example Output |
|----------|-------------|----------------|
| {{ticker}} | Symbol name | ES1!, NQ1! |
| {{exchange}} | Exchange name | CME, NYMEX |
| {{close}} | Current price | 5050.25 |
| {{time}} | Alert time | 2025-01-12T14:30:00Z |
| {{strategy.order.action}} | Buy or Sell | buy, sell |
| {{strategy.order.contracts}} | Position size | 1, 2, 5 |
| {{strategy.order.price}} | Order price | 5050.25 |
Advanced Webhook Configurations
Including Stop Loss and Take Profit
{
"symbol": "{{ticker}}",
"side": "{{strategy.order.action}}",
"quantity": {{strategy.order.contracts}},
"stopLoss": 10,
"stopLossType": "points",
"takeProfit": 20,
"takeProfitType": "points"
}
Multiple Account Execution
{
"symbol": "{{ticker}}",
"side": "{{strategy.order.action}}",
"quantity": {{strategy.order.contracts}},
"accountIds": [123456, 789012, 345678]
}
Common Webhook Errors and Solutions
Error: "Webhook URL is invalid"
Cause: The URL doesn't start with https:// or uses a non-standard port.
Solution: Ensure your webhook URL uses HTTPS and port 443 (default).
Error: "Webhook failed to send"
Cause: The receiving server didn't respond within TradingView's timeout.
Solution: Check that your webhook receiver is online and responding quickly.
Error: "2FA required"
Cause: Two-factor authentication isn't enabled on your TradingView account.
Solution: Enable 2FA in TradingView account settings.
Best Practices for Webhook Trading
-
Test with paper trading first - Always verify your automation works correctly before using real money
-
Use specific symbols - Instead of
{{ticker}}, you can hardcode the symbol to avoid mistakes -
Implement risk management - Set position limits and daily loss limits on your automation platform
-
Monitor your automation - Check order logs regularly to ensure everything is working
-
Have a kill switch - Always have a way to instantly stop all automated trading
Conclusion
TradingView webhooks are a powerful tool for automating your trading strategies. Combined with a reliable automation platform like RoboQuant, you can execute your strategies 24/7 on Tradovate and other brokers.
Ready to start automating? Get started with RoboQuant - it's free to begin.