Pine Script & Dhan
How to code a strategy in TradingView's Pine Script and automate its execution through Dhan, from the webinar we ran with the broker.
Last verified: 3 December 2026.
The world’s leading financial charting platform, TradingView, has a native scripting language called Pine. Traders can use Pine not only to code and test custom strategies, but now also to automate their execution through the webhook integration offered by Dhan.

This page accompanies a webinar we conducted in tandem with Dhan, covering the basics of Pine Script and automation. The Pine code described in the video can be downloaded here.
Disclosure: the TradingView and Dhan links on this page are referral links, and we may receive a benefit if you open an account through them. That does not change what the page says about the tools.
What the automation needs. Dhan’s TradingView webhook is a paid TradingView plan feature; the free plan cannot send webhook alerts. The downloaded script is Pine Script v5 (//@version=5). Automated webhook and API orders also fall under SEBI’s retail algorithmic-trading framework, mandatory since 1 April 2026: the order carries a unique exchange Algo ID, the strategy runs from a whitelisted static IP or a broker-hosted system, and API access needs OAuth with a daily two-factor login. Confirm your broker’s current onboarding for algo orders before relying on it.
Note that the Pine code does not describe a tested or recommended strategy. It is given here for educational purposes only.

