Information Trade Action Close by

Alexey Petrov  
Lucas INGLESE:
Hi, I read the MT5 python library documentation and I saw that to close a buy position, I need to use Trade action deal with order type sell. And the opposite for the sell position.

But, Can we close a position with mt5.TRADE_ACTION_CLOSE_BY? If yes, can you send me an example?

Close By is for closing a position with an opposite one (you need two positions).

For simple closure, you need to use TRADE_ACTION_DEAL. You can find an example here - https://www.mql5.com/en/docs/constants/structures/mqltraderequest. Just do the same via Python functions.

Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Structure
Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Structure
  • www.mql5.com
Trade Request Structure - Data Structures - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Raison: