Download MetaTrader 5
To add comments, please log in or register
MQL5 Reference is available in 8 languages. Learn MQL5 in the language that suits you best!
Armand
48
Armand 2012.02.12 21:40 

Hi, I have a question about the CTrade library.


When I have opened a position with a stop loss, one of two things can happen.

     1.    A condition is met and the position will be closed with the OrderClose() function.

     2.    A Stop Loss will be triggered, and the position will be closed automatically.


If case 2 happened:

      When my EA wants to close an opened position, how do I know that the position was already closed by the Stop Loss, so that I don't have to re-close that same position with my own OrderClose() call?


So how do I know if a position is open or closed?

Jin
1538
Jin 2012.02.13 06:48  
Armand:

Hi, I have a question about the CTrade library.

When I have opened a position with a stop loss, one of two things can happen.

     1.    A condition is met and the position will be closed with the OrderClose() function.

     2.    A Stop Loss will be triggered, and the position will be closed automatically.

If case 2 happened:

      When my EA wants to close an opened position, how do I know that the position was already closed by the Stop Loss, so that I don't have to re-close that same position with my own OrderClose() call?

So how do I know if a position is open or closed?

Use the CPositionInfo Library and check it.

Armand
48
Armand 2012.02.13 17:44  
Jin:

Use the CPositionInfo Library and check it.

Thanks, but I don't find any function in the library that can report if a position is open or closed. Could you tell me what would you do to solve this problem?
/
To add comments, please log in or register