Download MetaTrader 5

How can I find out if a position on an opened order has already opened?

To add comments, please log in or register
sarged
66
sarged  
I'm using pedning orders Sell Limit and Buy Limit. I open both orders at once, but if either position has been opened, I have to close another. The problem is i cannot find out wether my pending order has already opened a position or not. Because I send a pending order I can get a ticket number from the order result, but it's status doesn't change. Can you please clarify to me how this procedure can be done?
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
Alexey Da
Moderator
6648
Alexey Da  

Would you like to close existing position or to delete existing pending order?

You can try to select order by ticket using OrderSelect function. If your order has already opened position you will receive "false" and _LastError=4754.

Documentation on MQL5: Trade Functions / OrderSelect
  • www.mql5.com
Trade Functions / OrderSelect - Documentation on MQL5
sarged
66
sarged  
Well ok, I found out that too, but thanks still.
To add comments, please log in or register