Looks like you have not used the library reference. Would be able to check if you could share full code or exit code. Shall be able to guide accordingly
@Hardik @Dhan_Cares
I tried the integration with TradingView and Dhan via webhook.
None of my orders BankNifty and Nify got triggered.
Was following up Dhan support team since 9:30 am today. Didn’t get answered.
Then following up on mail, but did not get any reply.
Just now found this thread where it seems it’s existing issue at Dhan.
Please check and respond to my ticket.
Hi @Pankaj1
We have received your email, and we request you allow us some time to check your concern. We will update you on your registered email address.
It is working now. No issues.
Brokers are the last people on earth to whom we would like to give credit. Social media is flooded with posts that say “My broker did not help me square off positions…”, “My broker’s app stuck in between…”, “My broker did not help me login…” etc. I believe 99 out of 100 support tickets they get every day would be problems, glitches, and issues. Being a broker is such a thankless job, even if things worked correctly — their customers would say “They just met the expectations…”
Maybe they should change their name from “brokers” to “platforms”, because when we hear the word broker — we relate it with commissions. It started in real estate rentals. If you wish to rent a property, you need to pay 1 month’s rent as brokerage to the person who showed you the apartment. Similarly, the broker in stock trading connects you to the exchange — so that word rhymes with the concept of giving out some money as commissions.
My topic today is not about reducing the commissions or abolishing the list of taxes every trader faces, but something about giving credit for a job done well. This list tracks the 128+ brokers in India. Together they handle about 3,24,94,922 active customers. I assume that should be 95% of all traders. The top 10 brokers handle 80% of the customers. The top 20 handles 90%. This means around 108+ brokers handle just 10% of the customers.
Every broker has some pros and some cons. Switching from one broker to another is not that easy, so the customer will do that only if the new broker offers something extraordinary — a new tech or a pricing advantage. I am here to talk about one such tech that got me hooked — Trade via Charts.
TradingView (TV) is a firm that provides app/web based charting solutions for stocks, indices, currencies, and commodities. Most of the brokers provide free integration with TradingView charts. Trade from charts is not an entirely new feature, people outside India have been using it for a while now.
Dhan is one of the first brokers (15th in this list) that provided the TradingView integration via Webhooks. This means if we set some levels on the TV chart, it could place the orders directly on the Dhan app. This means a lot if you are serious about automating your trading plan. All we need to do is set the right levels on the TV charts via price alerts, pass the JSON script, and then set a corresponding order on Dhan app. If the stock/index crosses that price level — the system automatically places the order for you.
Dhan made this revolutionary integration and then quietly but suddenly it started gaining a lot of customers. Automated trading will attract the office-goers, self-employed professionals and part-time traders because they can set these levels on the chart and then forget it. This feature will help them take their eyes away from the trading screen and focus on their main job. Lesser screen time for trading combined with a higher focus on their main profession.
Lesser screen time also ensures lower stress levels. Sitting in front of the computer monitor for 6 to 7 hours watching the charts is not a child’s play. It not only eats up our energy but often prompts us to over-trade or exit prematurely.
This is how I created the price alert. In the message box you need to pass the correct Json as provided by the broker (for sample I have mentioned it as just TESTING…). Once this price alert is correctly set up — it places an order if Nifty50 falls below 18900. All I need to do is create a basket with the items that need to be part of the order. For example, see image below — I created a test basket with name: 111 that will place an order of 1 lot on 18900 PE when Nifty50 falls below 18900 on the TV chart.
If you are new to coding or automation — it may take some time to get a grip on what is happening. But once you have done the homework, it should work like a charm. I had no plans to open a Dhan account earlier, but as soon as this feature became stable — I wanted to try it. Now that I have been using it for half a year — I am really loving it. Once I got it working, the speed of placing the order was much better than my manual entries. I saved some slippage costs as well.
The important takeaway here is that automation is highly possible, but you need to set the command correctly. Automation is not a magic tool to help you make profits if you were losing manually. The logic of what should happen and when it should happen should be decided by you, how it will happen is what’s getting handled.
Also, trading is a tough job. Less than 5% succeed. 99% of trading money deployed ends up in the hands of 1% of traders. The real clue is to get your research worked upon. Work hard to find your edge. If you are employed somewhere, use your spare time or weekends to do the research. Once you are ready with a good plan — you may be able to deploy this feature. If you get it programmed correctly — it may even give you peace of mind.
# Automation using TradingView Webhooks, I got hooked on Dhan!
nifty buy ka to hai par exit k liye ???
Hi
Are you planning to include webhooks on mobile version
Hi @killedar.amit Good to see you after a while. No plans for this as of now; we are building Web more for traders.
Hi,
I tried to place an order of ABB future from ABB stock chart using an alert on TradingView using the webhooks and JSON as shown in the tutorial video but the alert got triggered in my TradingView Premium account but the order is not placed on Dhan. I am trying to shift to Dhan and use webhooks for orders and stoploss. But how do use it as I am unable to place the order as of now. The Alert got triggered during market opening itself at 9:15 but it did not place any order.
I just checked my Dhan account and the order was triggered it seems but got failed. Here is the error response in my Dhan account.
Response for Rejection
EXCH:17181 : Contract not traded. Market order not allowed
What does that mean. Why is market order not allowed.
Here was the JSON which was placed in TradingView in an alert and was generated by Dhan.
{“secret”:“4RbKm”,“alertType”:“multi_leg_order”,“order_legs”:[{“transactionType”:“B”,“orderType”:“MKT”,“quantity”:“1”,“exchange”:“NSE”,“symbol”:“ABB1!”,“instrument”:“FUT”,“productType”:“M”,“sort_order”:“1”,“price”:“0”}]}
I placed this code in the ABB chart in TradingView. Is there something wrong that I did. Please reply back as I plan to use webhooks both for purchase but more importantly for stoploss in future trading by using the stock chart in TradingView. I am a Zerodha user and the only problem with Zerodha GTT which is very reliable is that futures prices fluctuate a lot and it just takes out my stoploss in GTT whereas the stock chart do not match all the time. But one good option in Zerodha which I have used all these years is that GTT is available in the Order screen while buying the future or stock. So, it is instantly placed with the order placement.
I need to use the Webhook alert mainly for stoploss as I lose money due to slippage in Zerodha. I plan to place stoploss in my stock futures positions by using the stoploss I see in the stock chart (I plan to trade futures using stock chart in TradingView). Please someone help as I am still trying to learn Dhan and TradingView webhooks especially for futures before shifting completely to Dhan.
Hello @zaman
Great to see you exploring Webhooks!
For F&O, since the alert was triggered at 09.15, Market orders are not allowed at market opening i.e. first order matching at exchange is of limit orders and then Market Orders are placed.
If you wish to trade in futures, then you can directly connect Dhan from Trading Panel on TradingView.com and trade without webhooks too.
Hello @Hardik ,
Thanks a lot for the explanation. I tried with 2 more order placements using webhooks in futures later today and both of them got executed. I later checked the time of the first order of ABB future that got failed and saw that the time of execution was 9:15 AM and so, I got an idea and tried two more order placements using Webhooks and both succeeded.
I have purchased 3 future lots of 3 different stocks and I am using webhooks to set stoploss and target too and I hope that the stoploss and target through webhook also gets triggered on time so that I avoid heavy losses. If everything works well, I will hopefully shift almost all my trading to Dhan in the near future. I want the webhooks to be reliable so that I can avoid slippage which happened in Zerodha due to sudden spikes in futures charts/price compared to actual stock chart/price.
The reason I am not planning to trade directly using TradingView Trading Panel as of now is because I rely more on the stock chart compared to the futures chart. The indicators and alerts work far better in the stock charts/prices compared to the futures charts/prices and I am trying to trigger the alerts with webhooks wherever possible.
I am using Dhan for the first time today and I hope it works out smoothly. Trades will also go against me which is very logical but I want the stoploss to be triggered immediately as per the stock price (based on alert or price as per my calculation) so that I can reduce heavy losses which used to happen a lot of time in Zerodha. They have an excellent trading platform and is very stable but the main demerit is that futures charts and stoploss/target are not as reliable as stock charts. Hopefully I can resolve this issue by using TradingView webhooks for triggering stoploss from now on.
Hello @Hardik ,
Thank you for the help. It is working as of now but some of the orders are getting skipped. I have tried futures with webhooks mostly for stoploss and target (most hit stoploss as the market has sort of fluctuated in the last couple of days) but I noticed that many of the webhook orders are not getting executed. At least 30-50 percent of the Webhook orders are getting skipped. I clearly remember at least 3 futures stoploss orders skipping and I had to manually close them yesterday and today. The alerts are showing fine in Tradingview but it is not getting executed here in my Dhan account. How reliable are webhooks as I am keeping close stoploss to avoid heavy losses even if the market fluctuates.
If the alert logics are set correctly, then this issue shouldn’t happen. Any chance you are using two different webhook URLs? Or which JSON are you using for Stoploss alerts?
@Hardik ,
Thank you for the quick reply. I had copied the code directly from my webhooks generated from inside Dhan to my TradingView account. I clearly remember 3-4 future orders (stoploss in all cases as my targets are normally bigger than stoploss) where the stoploss did not get triggered although the alerts got activated inside tradingview. In some cases, I tried restarting the same stoploss again to test out but still it did not work. A few futures stoploss/orders I remember that did not get executed since yesterday are TCS January future, DLF January future, Ramco Cement January future and Polycab January future. I had to manually close all four of them. I remember trying to restart the alert in at least Ramco Cement and DLF futures. But still it did not get processed the second time and I had to close them manually. In fact, I noticed that unlike yesterday where it showed up as failed in my Dhan account when the alert was generated at 9:15 AM, it did not even show up in my Dhan account today. Only the alert was displayed in TradingView but it did not show up in Dhan. I am generating all the webhook JSON from my Dhan account and my webhook URL is active for 30 days. So, I am not sure why the issue is happening.
If you wish, I can copy paste the alerts if it happens again tomorrow.
Yes, sure that will help. You can also send your Client ID on DM, will check log after markets are closed and can update you accordingly.
Hello Hardik
The pdf document describing how to use webhooks is not comprehensive. For a new comer, it will not be understood, that is the reason users are raising similar questions.
You need to add complete details with one example of equity and options segment.
For options, u need to add for call buy and exit, put buy and exit.
For dynamic auto trading , process to follow.
Hello @killedar.amit
Thank you for the feedback. Yes, will make an even detailed PDF, or add video snippets.
When? This is incompleted reply. Can you please clear the current query on how to do.