**need clarity on JSON Message format to place automated orders via tradingview alerts**

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.

{
“secret”: “x11X1”,
“alertType”: “multi_leg_order”,
“order_legs”: [

{“transactionType”: “{{strategy.order.action}}”,
“orderType”: “MKT”,
“quantity”: “{{strategy.order.contracts}}”,
“exchange”: “{{exchange}}”,
“symbol”: “{{ticker}}”,
“instrument”: “EQ”,
“productType”: “C”,
“sort_order”: “1”,
“price”: “0”
}
]
}

**Questions **
what are the valid values (with description) that we can enter for

  1. transactionType (i.e Buy, Sell, Exit position)
  2. orderType (MKT, Buy if the price goes below Rs X, Sell when price goes above RsY.
  3. quantity fix, % of equity etc
  4. instrument EQ, OPT, FUT etc
  5. 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.

Hello @arundengri

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.

@Hardik ,

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
code.
2. Exit all positions.

Hello @arundengri

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.