Automated placing orders on Dhan thru TV Alerts, webhook and JSON. messsage
Other things are clear. below JSON example caters to only the simplest order.
my questions are after the JSON below.
what are the valid values (with description) that we can enter for
- transactionType (i.e Buy, Sell, Exit position)
- orderType (MKT, Buy if the price goes below Rs X, Sell when price goes above RsY.
- quantity fix, % of equity etc
- instrument EQ, OPT, FUT etc
- productType “C”, “?”, “?”
6 how to place stop lot and take profit price.
7. how to enter a comment while placing an order.
this is needed, so we know which strategy, which timeframe, an order was placed. this will be very usefull for us to identify which strategies work on which symbol and timeframe.
Great to know that you are exploring Dhan Webhooks via TV alerts.
To save time for end users like you, we have made it really simple to generate JSON via Orders section in web.dhan.co. This is so that you do not have to remember values that needs to be passed in the JSON. If you are looking to handle any particular scenario, do let us know and we will try to help you with that.
How do I place the below orders (scenario)
A.1. I want to buy equity with “stop loss” (automatic exit position if the loss reaches 10%)
A.2. I want to buy equity with “take profit” (automatic exit position if take profit reaches 15%)
Stop loss 10% = when the current price reach 90% of the original buy price, then sell at loss.
Take profit 15% = when the current price reaches 115% of original buy price.
B Suppose I had three buy orders one after another say buy1, buy2, buy3. Later on, I want to
1. Exit from buy2, how do I do that, can I fetch my dhan order # that can be fetched in the
2. Exit all positions.
Since we are looking at webhooks here, a lot of automated customisability can be done if you use Webhooks with PineScript.
For A, you can use multiple triggers at different price points on the chart to create stop loss and take profit orders.
For B, You can see your open orders on tradingview.com, if you have connected Dhan as broker (for equity and futures). You can then use this to exit manually from there.
For exiting all positions, this needs to be done via web.dhan.co only, as this functionality cannot be made available on TradingView platform.