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

hi @Hardik ,
Does the sort_order input will ensure the sequence of execution in a multileg order ? E.g I have few hedge buy legs up the sequence followed by SELL legs . Want to know if SELL legs will be executed post hedge leg execution . Kindly respond please.

{‘secret’: ‘xxxx’, ‘alertType’: ‘multi_leg_order’, ‘order_legs’: [{‘transactionType’: ‘B’, ‘orderType’: ‘LMT’, ‘quantity’: ‘10’, ‘exchange’: ‘NSE’, ‘symbol’: ‘NIFTY’, ‘instrument’: ‘OPT’, ‘productType’: ‘M’, ‘sort_order’: ‘1’, ‘price’: ‘38.43’, ‘option_type’: ‘CE’, ‘strike_price’: ‘24600’, ‘expiry_date’: ‘2024-12-19’}, {‘transactionType’: ‘B’, ‘orderType’: ‘LMT’, ‘quantity’: ‘10’, ‘exchange’: ‘NSE’, ‘symbol’: ‘NIFTY’, ‘instrument’: ‘OPT’, ‘productType’: ‘M’, ‘sort_order’: ‘2’, ‘price’: ‘23.99’, ‘option_type’: ‘PE’, ‘strike_price’: ‘24000’, ‘expiry_date’: ‘2024-12-19’}, {‘transactionType’: ‘S’, ‘orderType’: ‘LMT’, ‘quantity’: ‘10’, ‘exchange’: ‘NSE’, ‘symbol’: ‘NIFTY’, ‘instrument’: ‘OPT’, ‘productType’: ‘M’, ‘sort_order’: ‘3’, ‘price’: ‘101.56’, ‘option_type’: ‘PE’, ‘strike_price’: ‘24300’, ‘expiry_date’: ‘2024-12-19’}, {‘transactionType’: ‘S’, ‘orderType’: ‘LMT’, ‘quantity’: ‘10’, ‘exchange’: ‘NSE’, ‘symbol’: ‘NIFTY’, ‘instrument’: ‘OPT’, ‘productType’: ‘M’, ‘sort_order’: ‘4’, ‘price’: ‘115.81’, ‘option_type’: ‘CE’, ‘strike_price’: ‘24300’, ‘expiry_date’: ‘2024-12-19’}]}

Hello @jacharjya1978

Yes, it is for sequential order execution. But do note that this does not guarantee execution if e.g. BUY leg itself stays in pending state, due to time taken in order matching.

Thanks for responding , so there could be a possibility BUY order pending up in the sequence , SELL leg will be tried to execute meanwhile . It could lead to margin issue.
May be I will opt MKT order for buy legs …what do you suggest ?

@Hardik Further more , can it be possible to add a wait (which may take few seconds as input) field in the json for a specific leg , so that SELL legs can be delayed for few seconds. It would help to get rid of margin issues .

Hello @jacharjya1978

This is certainly better, as LIMIT orders have a higher chance of creating this scenario.

Right now, this is not. Essentially, we will have to implement delayed order execution for legs, wherein the second leg is only sent if the first leg is successfully executed. Will have to check feasibility of this, as this will keep threads busy at our end for longer period of time.

@Hardik understood …as through webhooks we dont have much control to delay the specific legs on client side , appreciate if you consider this. Otherwise sequential execution of orders (sort_order) does not have any significance.

1 Like

Hi! Not sure if this thread is still active but it would really help to have a OCO type webhook. I usually use these webhook alert to set market orders at SL and TP once I have entered into a position. But I still need to be vigilant enough to cancel the one counterpart order myself once one of them is executed.

Hello @Chhavi_Atal

Welcome to MadeForTrade community!

Yes, advanced order types like OCO is something we haven’t yet introduced on Webhooks and remains on the roadmap. Will definitely look into the feasibility of this.

Thank Hardik, this is a very valuable feature for traders and will definitely set Dhan apart. If possible, please prioritize it

dhan webhook can be used only for oneway trade… the strategy i used is working with binance webhook, but in dhan its triggering only entering the trade and not exiting the same… if we write exit code with another secret key, the previous buy also get triggered and quantity mismatch occurs

is the buy and sell automatically executed with desired quantity ? like closing the long position and creating a short position

does having an DHAN account enables to use TRADINGVIEW PRO for free ? if its true how to enable it

Hi @Gobi_Nath,

We offer a hosted version of TradingView at tv.dhan.co.

With Dhan’s seamless integration, you can enjoy lightning-fast execution directly from the TradingView platform. To access these features, simply ensure you have the necessary TradingView subscription.

am looking for webhook integration. automated buy or sell is not working properly

Hello @Gobi_Nath

Can you tell us more about this? You can share the code for entry/exit positions and we can look into it?

is there any telegram or whatsapp link to chat with u?

buy and sell signals are generated as per strategy ,but since the “transaction”: " B" and "“S” is given in different alert, (same strategy), buy order is executed when there is a exit long signal from strategy and a sell entry order is executed… is there anyway to communicate with u instantly ? we get response from u after hours

Buy, Sell, Short, Cover all can be executed automatically. But you need to do your pine script accordingly.

You can get a sample refrence code here.

this code works well in BINANACE WEBHOOK… but in dhan “transaction”:“B” is only given, where as in BINANCE WEBHOOK “transaction”:“BOTH” is given.( it indicates BUY or SELL) here in dhan another secret key and alert message has to be provided for “transaction” : “S” but buy order is executed twice when BUY and SELL is generated from strategy