coding _ close position by order type (mql5)

 

hi all,


i'm trying to create my own expert adviser. However, i don't know the coding (mql5) that for close the opened position by (OrderType() == OP_BUY) or (OrderType() == OP_SELL).

It is so much different with mql4.

Kindly share a sample coding (mql5) for the below situation.


if condition A, then close all the opened position (long/buy)

if condition B, then close all the opened position (short/sell)


Thank you.

 
Alex Wong:

hi all,


i'm trying to create my own expert adviser. However, i don't know the coding (mql5) that for close the opened position by (OrderType() == OP_BUY) or (OrderType() == OP_SELL).

It is so much different with mql4.

Kindly share a sample coding (mql5) for the below situation.


if condition A, then close all the opened position (long/buy)

if condition B, then close all the opened position (short/sell)


Thank you.

Please read the document about your problem here.

https://www.mql5.com/en/docs/constants/tradingconstants/enum_trade_request_actions
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Trade Operation Types - Reference on algorithmic/automated trading language for MetaTrader 5