Introducing: Webhooks as Order Type on Dhan. Now do Options Trading on Dhan Charts

Hi @t7support,

This Friday, most of my alerts were triggered but nothing happened on Dhan. There were no errors on either Dhan or TradingView. It had been working fine all week, and the endpoint is still active.

Webhooks seem to be very unreliable, any advice on how I can debug this? Since you’ve been using it for a long time, your insights would be really helpful. For context, I’m using webhooks on an indicator alert to execute baskets on Dhan.

Thanks

Hi @longtrader,

This change in the terms and conditions looks pretty scary.

This change in TradingView’s T&Cs could kill webhook trading.
@PravinJ your thoughts?

I’m surprised Dhan hasn’t warned users about this yet, many rely on the TradingView webhook integration and could be caught off guard.

@jaison I didn’t have any issue on Friday.

I would check the following again

  1. Webhook Url active ?
  2. Basket JSON correct ? JSON need to be generated after webhook URL generation!
  3. Check TV alert logs and see whether the JSON being passed is the one expected at Dhan end.
  4. Basket is not empty and orders are added ?
  5. TV paid plan and alerts active ?
  6. Does the system fire TV alerts at high frequency ? In that case some alert messages may not get through to Dhan side
  7. TV alert server status and downtime

If all these are ok then only Dhan guys can help with further debugging.

2 Likes

I too faced the same issue. I have raised this issue, but to my surprise no one could understand and explain why it is breaking only for Sell orders.
If it is because of insufficient funds, then should it not get triggered and then fail like in case of a Buy order?

Raised it on this forum with @Shubham_Singh and on help@dhan with Shrutika.

@punitrnair Post u r issue here and may be I can be of help.

Are orders getting to Dhan and failing ? If not we need to focus on ur script and alert JSON strings being passed to Dhan via webhook for sell orders.

Hey @jaison @longtrader

While we haven’t received any communication from TradingView themselves on this and possible ban of any accounts for using webhooks, we are keeping a close check on it.

As of now, thousands of users across Dhan continue to use webhooks for placing orders. While we cannot alter the policies of TradingView, we are working to ensure you can continue place orders based on conditions without any issue. Will soon have more updates on this.

1 Like

What I have figured is that webhook with JSON productType ‘C’ and transactionType - S is failing.

The following alert failed to even show up on DHAN

<continued in the thread below, since only 1 embedded image is allowed per comment>

Not sure how dhan process the JSON val. It seems the order of keys are different. Usually it doesn’t matter but something for you to check.

{“secret”:“xxxxx”,“alertType”:“multi_leg_order”,“order_legs”:[{“transactionType”:“S”,“orderType”:“MKT”,“quantity”:“10”,“exchange”:“NSE”,“symbol”:“GODFRYPHLP”,“instrument”:“EQ”,“productType”:“C”,“sort_order”:“1”,“price”:“0”}]}

while the below one was successful.

the only difference of contextual relevance, is the change from C to I in productType

Did that, the order is not a problem.

I am not able to place a “productType”:“C”, “transactionType”:“S”

Your secret code is different in both screenshots. Secret code needs to be active and should be generated after the webhook URL generation.

Also we cannot short sell stocks in Delivery mode. Indian market regulations don’t allow for that.

yeah, the secret key is different was because the webhook was refreshed.

The point I understand that Delivery mode Sell order isnt allowed, but then does Dhan take a Intraday sell order and close the opposite open Long order correctly?

For ex. If I have a delivery Long position open for 5 units, does placing a Sell order with Intraday type for 5 units enough to close the long position?

No intraday and delivery are different product types. Placing an Intraday sell won’t exit your shares in demat account (Delivery mode).

and that is the core issue. How do I place an order to close the open Long order of a Delivery type?

Sell order also need to be of the Delivery type

and the Dhan systems are not processing it.
I haven’t got any Delivery type Sell orders being processed

Naked Delivery Sell order is banned in the market. But if you already have N number of Delivery holdings of a stock and selling fails with a Delivery product type then only Dhan can help @Hardik

1 Like

Thanks
Also looping in @Shubham_Singh

Hi @punitrnair

It seems you may not have activated the DDPI, or you might not have verified your holdings via E-DIS before placing the sell order through webhook.

Please confirm if these steps were completed and the order still did not go through.

Hi @Hardik my json message has “orderType”:“LMT” along with “price”:“75” but when the alert triggered on Tradingview the order is not showing in Dhan order section. Please can you check if limit order works fine using Webhook alert.

Sample json message

{“secret”:“DzDRA”,“alertType”:“multi_leg_order”,“order_legs”:[{“transactionType”:“B”,“orderType”:“LMT”,“quantity”:“1”,“exchange”:“IDX”,“symbol”:“NIFTY”,“instrument”:“OPT”,“productType”:“M”,“sort_order”:“1”,“price”:“75”,“option_type”:“PE”,“strike_price”:“25000.0”,“expiry_date”:“2025-10-14”}]}