How to Automate TradingView to DhanHQ and Angel One
Algo trading in the Indian stock market has never been more accessible. With TradingView’s powerful Pine Script and webhook capabilities, retail traders can now build fully automated, institutional-grade execution systems.
In this guide, we’ll walk through how to send TradingView alerts to DhanHQ and Angel One via Tradehook, ensuring lightning-fast execution for Nifty and BankNifty options.
What is a Webhook?
A webhook is a simple, automated HTTP POST request sent by one application to another when a specific event occurs. In the context of trading, when your TradingView strategy generates a Buy or Sell signal, TradingView instantly fires a webhook payload containing the order details.
TradingView webhooks are the bridge between your technical analysis and live market execution.
Step 1: Set up your API Credentials
Before TradingView can place a trade, you need to give Tradehook permission to execute orders on your behalf.
- DhanHQ: Go to web.dhan.co and navigate to the "API & Webhooks" section to generate your Client ID and Access Token.
- Angel One: Log in to smartapi.angelbroking.com and create a new App to get your API Key and Secret.
- Open Tradehook, navigate to Broker Settings, and paste in your credentials.
Step 2: Configure your TradingView Alert
Once your strategy is ready on the chart, click the "Create Alert" button in TradingView.
- In the Condition dropdown, select your strategy.
- In the Notifications tab, check Webhook URL.
- Paste your unique Tradehook webhook endpoint:
https://api.tradehook.in/v1/webhook/YOUR_UNIQUE_ID
The JSON Payload
In the "Message" box of the TradingView alert, you must send a structured JSON payload so Tradehook knows exactly what to trade:
{
"symbol": "BANKNIFTY",
"action": "{{strategy.order.action}}",
"quantity": 15,
"product": "MIS"
}
This payload dynamically fills in Buy or Sell depending on what your strategy did, and tells Tradehook to buy 15 quantity (1 lot) of BankNifty as an Intraday (MIS) order.
Step 3: Map to Options (Optional)
If you are trading indices, you likely want to execute Options rather than Futures. Tradehook’s engine automatically parses the webhook and can dynamically select the ATM strike!
- Check out the Strategy Builder inside Tradehook to visually map your TradingView signals to complex multi-leg options strategies.
Conclusion
By connecting TradingView to Tradehook, you remove the emotion from trading. Your system watches the market 24/7, catching the exact breakout or breakdown and executing the trade in milliseconds before human fingers can even react.
Ready to start? Head over to your dashboard and create your first Webhook connection today!