SELL order syntax and auto ATR trail

Hi Dhan Team,
I think this community is to guide if client is having any queries but i didn't getting proper response since few queries. Purpose of to open account in dhan sis that i will be able to do automation trading by myself.
hence kindly guide us for our doubts.

dhan trade hall pypi.org, Link syntax for buying order is available but sell orer is not mentioned, how to give SL and target order kindly confirm me.

EX:suppose
ltp= 1201 for SBI

base_sl = round(ltp * 0.70, 1)
target = round(ltp * 1.30, 1)

SL syntax at lower level

===============

orderid = tsl.order_placement(‘SBIN’,‘NSE’, 1, 1190, 0, ‘STOPMARKET’, ‘SELL’, ‘MIS’)
orderid = tsl.order_placement(‘SBIN’,‘NSE’, 1, base_sl, 0, ‘STOPMARKET’, ‘SELL’, ‘MIS’)

orderid=tsl.order_placement(tradingsymbol=ce, exchange=“NFO”, quantity=qty, price=base_sl - 0.10, trigger_price=base_sl, order_type=“STOPLIMIT”, transaction_type=“SELL”, trade_type=“MIS” )

orderid=tsl.order_placement(tradingsymbol=ce, exchange=“NFO”, quantity=qty, price=base_sl, trigger_price=0, order_type=“STOPMARKET”, transaction_type=“SELL”, trade_type=“MIS” )

Selling target syntax at higher level

===========================

orderid = tsl.order_placement(‘SBIN’,‘NSE’, 1, 0, target, ‘LIMIT’, ‘SELL’, ‘MIS’)

orderid = tsl.order_placement(‘SBIN’,‘NSE’, 1, 0, 0, ‘MARKET’, ‘SELL’, ‘MIS’)

I want partial exit at 30% then which one is correct sell syntax:

        if ltp >= p["target"] and "partial" not in p:

            tsl.cancel_order(p["sl"])

            tsl.order_placement(tradingsymbol=opt, exchange="NFO", quantity=p["half"], price=0, trigger_price=target, order_type="LIMIT", transaction_type="SELL", trade_type="MIS" ) # Is this syntax correct

 tsl.order_placement(tradingsymbol=opt, exchange="NFO", quantity=p["half"], price=0, trigger_price=0, order_type="MARKET", transaction_type="SELL", trade_type="MIS" ) # Or this is proper syntax correct



kindly guide me, waiting for your reply. I want syntax only so don’t think you will ask for full code

Regards

Krishna

Hi @Krushna_Rout ,

You can use the below code-

if ltp > target_price:

    sell_order_id = tsl.order_placement(tradingsymbol=opt, exchange="NFO", quantity=p["half"], price=0, trigger_price=0, order_type="MARKET", transaction_type="SELL", trade_type="MIS" ) 
# since we are already comparing target price with LTP you can use Market SELL order to exit