@Imran Ji, @ Dhan
If I want to Exit on Certain%
# Place the STOP loss order with STOPMARKET execution
tsl.order_placement(stock_name, 'MCX', qty, 0, sl_price, 'STOPMARKET', 'SELL', 'MIS')
Where I need to Feed the exit% ?
@Tradehull_Imran
Do you mean you want to exit on predefined values? @Hemal_Chhatrala
Better use bracket order, and for the % I think you have to do the calculations on your own in the previous line of code, then you can insert the variable in
bo_profit_value=your_value, bo_stop_loss_Value=your_value
also don’t forget to use ‘‘BO’’ instead of ‘‘MIS’’
if you want to do it without Bracket, order, you need to do the calculations in the previous line anyway, and then insert the sell order on the limit at that price.
1 Like
any example for Option Trade BO Order ?
I am really struggling to put stop loss and target order in my option Algo.
My code is completely ready, Order placing on time by Algo, but its without stop loss and target orders - I don’t know why… 
Hi Hemal,
target = 10
stop_loss = 5
take_profit = 1 + (target * 0.01)
take_loss = 1 - (stop_loss * 0.01)
entry_price = current_price # ltp
stop_loss_price = entry_price * take_loss
stop_loss_distance = entry_price - stop_loss_price
target_price = entry_price * take_profit
target_distance = target_price - entry_price
at_time = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
if not paper_trade:
order_id = trade_hull.order_placement(
tradingsymbol=stock,
exchange='NFO',
quantity=quantity,
order_type='MARKET',
transaction_type='BUY',
trade_type='BO',
bo_profit_value=target_distance,
bo_stop_loss_Value=stop_loss_distance,
)
As far as I know, for bracket order, you have to place absolute values.
meaning if the buy price is 100,
and you want stop loss at 80, and take profit at 120,
in bo order, you would put 20 for stop loss and also 20 for take profit, both values positive.
try the code above (I mean the target_distance
, and stop_loss_distance
) variable calculation part.
maybe test it live with a really small amount of money, I have not tested it yet, since the market is close today.
1 Like