Using the MetaTrader 5 Python library, How can i set take profit orders for open positions that execute like limit orders instead of market orders

 

As the title says i want to take profit on open positions that execute like limit orders to avoid crossing the spread or incurring slippage. TRADE_ACTION_SLTP allows you to set a take profit price that the order is execute at but the actual execution acts like a market order.

Here is my current code:

# Get open positions positions=mt.positions_get(symbol=symbol) for position in positions: if position.type == 0: request = { "action": mt.TRADE_ACTION_SLTP, "position": position.ticket, "type": mt.ORDER_TYPE_SELL_LIMIT, "tp": current_average_position_price+2, "symbol": position.symbol, "type_time": mt.ORDER_TIME_GTC, "type_filling": mt.ORDER_FILLING_IOC,} mt.order_send(request)