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?
- How to close an order
- MQL5 CloseTradeFunction
- Experts: DoubleZigZag
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.
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
- www.mql5.com
Trade Request Structure - Data Structures - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5

Vous manquez des opportunités de trading :
- Applications de trading gratuites
- Plus de 8 000 signaux à copier
- Actualités économiques pour explorer les marchés financiers
Inscription
Se connecter
Vous acceptez la politique du site Web et les conditions d'utilisation
Si vous n'avez pas de compte, veuillez vous inscrire