Learn Algo Trading with Python | Codes | Youtube Series

Hi @Rajashekhar_Rangappa

See reference code,


				options_name                      = orderbook[name]['options_name']
				options_chart                     = tsl.get_historical_data(tradingsymbol = options_name,exchange = 'NFO',timeframe="5")
				options_chart['atr'] 			  = talib.ATR(options_chart['high'], options_chart['low'], options_chart['close'], timeperiod=14)
				rc_options                        = options_chart.iloc[-1]
				sl_points                         = rc_options['atr']*atr_multipler
				options_ltp                       = tsl.get_ltp_data(names = options_name)[options_name]
				tsl_level                         = options_ltp - sl_points

				if tsl_level > orderbook[name]['tsl']:
					trigger_price = round(tsl_level, 1)
					price         = trigger_price - 0.05
					tsl.modify_order(order_id=orderbook[name]['sl_orderid'],order_type="STOPLIMIT",quantity=25,price=price,trigger_price=trigger_price)
					orderbook[name]['tsl'] = tsl_level

Also, do use this codebase file : Dhan_Tradehull_V2.py - Google Drive

1 Like