Close partially an order USING Python

 
Hi, I use MT5 through Python and not the usual interface.

And I do not find answer to my question: How can I partially close an order using Python (because I do not find any functions or that)?

Thanks in advance!
 
Lucas INGLESE: Hi, I use MT5 through Python and not the usual interface. And I do not find answer to my question: How can I partially close an order using Python (because I do not find any functions or that)? Thanks in advance!

In the same way you do a full close, just with a different volume.

Closing a position means using order_send with the trade action TRADE_ACTION_DEAL, referencing the existing position's id ticket in the "position" field of the MqlTradeRequest structure.

But instead of using the full amount for "volume" field if the existing position, you simply use a partial volume.

Documentation on MQL5: Integration / MetaTrader for Python / order_send
Documentation on MQL5: Integration / MetaTrader for Python / order_send
  • www.mql5.com
order_send - MetaTrader for Python - Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5