Introducing Webhook Alerts : Direct Order Placements on TradingView from Dhan

The 500 error message is from Trading view team from the response log they have. Not from the postman or direct api calls. Already sent message to support team from monday, every time I get reply like will get back to you in 24hrs. But never got a proper response. This is a simple check at your side if the service is running or not and get it fixed. Not sure why it takes so much time. At dhan, if its all working; all good, any issues then its hard to get it resolved.

Hello @Market_Wizard

I get the usecase, but this might be difficult to solve for. Trading Notes on Dhan can only be added after the order has been executed (traded on the Exchange). So essentially, it is after your position is created.

On Webhooks, since JSON only helps with order execution, it will be difficult to map it to position later and thus, showing notes on it becomes difficult.

Hello @Hardik ,

Alerts are getting triggered from trading view, However order is not getting placed.

{“secret”:“xxxx”,“transactionType”:“B”,“orderType”:“LMT”,“quantity”:“1”,“exchange”:“NSE”,“symbol”:“HDFCBANK”,“instrument”:“EQ”,“productType”:“C”,“sort_order”:“1”,“price”:“1678”}

Can you please share your tv alert message log snapshot ?

Pine script For Buy and Sell Alert

buyData = ‘{“secret”:"’ + secretInput + ‘“,“transactionType”:“B”,“orderType”:”’ + Ordertype + ‘“,“quantity”:”’ + str.tostring(Qty) + ‘“,“exchange”:”’ + str.tostring(syminfo.prefix) + ‘“,“symbol”:”’ + syminfo.ticker + ‘“,“instrument”:”’ + Instr + ‘“,“productType”:”’ + Prodtype + ‘“,“sort_order”:“1”,“price”:”’ + str.tostring(math.round(close)) + ‘"}’
sellData = ‘{“secret”:"’ + secretInput + ‘“,“transactionType”:“S”,“orderType”:”’ + Ordertype + ‘“,“quantity”:”’ + str.tostring(Qty) + ‘“,“exchange”:”’ + str.tostring(syminfo.prefix) + ‘“,“symbol”:”’ + syminfo.ticker + ‘“,“instrument”:”’ + Instr + ‘“,“productType”:”’ + Prodtype + ‘“,“sort_order”:“1”,“price”:”’ + str.tostring(math.round(close)) + ‘"}’

Please send u r actual alert log message for debugging. Not the alert string construction with syntax and user defined variables about which I don’t have a clue.

Other than the secret code there is nothing that is personalized to really hide in the generated alert string.

Alert ID Ticker Name Description Time
1122627735 NSE:HDFCBANK, 30m {“secret”:“Q0rJI”,“transactionType”:“B”,“orderType”:“LMT”,“quantity”:“1”,“exchange”:“NSE”,“symbol”:“HDFCBANK”,“instrument”:“EQ”,“productType”:“C”,“sort_order”:“1”,“price”:“1678”} 2023-12-26T06:45:01.000Z
1122628039 NSE:JIOFIN, 30m {“secret”:“Q0rJI”,“transactionType”:“S”,“orderType”:“LMT”,“quantity”:“1”,“exchange”:“NSE”,“symbol”:“JIOFIN”,“instrument”:“EQ”,“productType”:“I”,“sort_order”:“1”,“price”:“235”} 2023-12-26T06:15:01.000Z

Seems good to me. Is the webhook url still active and corresponds to the secret code in alert message ?

I had reached out to Dhan support they had suggested to regenerate the Webhook and Secret, Still the order are not getting placed.
Webhook is active until Jan 25th 2024.

Hello @jayaraman

This looks like the old JSON format that earlier webhooks had. Although the same is still active, can you try with the current webhook JSON format? You can generate one from web.dhan.co > Orders > Webhooks

@PravinJ @Hardik

Alert ID Ticker Name Description
1128205235 NSE:COALINDIA, 30m {“secret”:“og1HR”,“alertType”:“multi_leg_order”,“order_legs”:[“transactionType”:“S”,“orderType”:“LMT”,“quantity”:“1”,“exchange”:“NSE”,“symbol”:“COALINDIA”,“instrument”:“EQ”,“productType”:“C”,“sort_order”:“1”,“price”:“375”}]}

Alerts are triggered from tradingview and its not getting placed in dhan with the new JSON format

Is there any way to check if the signal received to dhan, also what is the validity of the order is that IOC or dayorder[Validfortoday]

Hello @Hardik and the Dhan Team,

I am planning to shift to Dhan from another broker mainly for the Webhooks feature. I am already a premium customer of Tradingview and so, I plan to utilize the webhooks features for triggering and placing orders as well as selling orders as stoploss for existing positions. I want to use this for all segments including futures and equity which are the two main segments I deal in. I mostly trade on positional basis in futures and equity more than intraday. The main problem I faced with the other brokers is that the GTT for futures is based on the futures price but I like to trade based on stock price and not future price. I have already added some funds to start trying Dhan. But I have a couple of questions I would like to ask.

  1. Can I enable either future purchase or sell using the alert in stock/equity chart in Tradingview. I want to purchase stock future when the stock price reaches a definite price or indicator alert and I want to sell stock future when the stock price reaches stoploss or price based on indicator.

  2. I tried generating the JSON in my Dhan account for futures and tried to place them in my stock chart in TradingView Premium. But when I tried to generate the futures JSON it is now showing which month futures. For example, it can be either January future or Februrary future. Which month future does it purchase when I purchase or sell a future.

Thank you a lot. I plan to be a long term and regular user of Dhan if the webhooks work properly as I like to set stoploss based on indicator or candles compared to futures charts. Please respond to my above query.

Hello @zaman

Welcome to Dhan Community! Great to see you trying out Dhan Webhooks.

Here is an answer to your questions:

  1. Yes. You can place an alert on any instrument (in this case underlying equity) which when triggered will place order for the intended instrument (in this case, Futures). You just need to generate JSON for the instrument in which you want to place order in.
  2. For Futures, we currently have only current month futures enabled via Webhooks.

Hope this helps!

Hello @Hardik

Today as well Alert triggered from trading view and there was no order placed in dhan

1 Like

Hello @jayaraman

Can you share your Client ID on DM, will have this checked and connect with you.

How to use tradingview pinescript strategy using webhooks for auto trading.
Do we need to alter in pinescript strategy for auto buy and sell OPTIONS CALL AND PUT BUY

Webhooks are not working for me, not sure why. Have tried a lot.

Is there any YouTube video available for this?

hi @Saurabh0053 You will find it here: https://www.youtube.com/watch?v=KwOcnzmtXIQ

Thank you for your help, I will watch it