Download MetaTrader 5

Current profit on an open position

To add comments, please log in or register
Have you made a screenshot in MetaTrader? Share it with friends!
BigAl
489
BigAl 2013.03.07 10:06 

I feel stupid!! I can not find out how to get the current profit of an open position. tried lots of things like if (OrderSelect(ticket) Print("Profit = ", Profit());

but compiler says Profit function not defined although its in the documentation.

Help Please

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Position Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Position Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Position Properties - Documentation on MQL5
Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2013.03.07 10:17  
BigAl:

I feel stupid!! I can not find out how to get the current profit of an open position. tried lots of things like if (OrderSelect(ticket) Print("Profit = ", Profit());

but compiler says Profit function not defined although its in the documentation.

Help Please

There can be no profit on an Order only on a Position. 

Why don't you use PositionGetDouble()  with POSITION_PROFIT  ?

 

Perhaps you should be using Select()  rather than OrderSelect() ? 

BigAl
489
BigAl 2013.03.07 10:21  
RaptorUK:

There can be no profit on an Order only on a Position. 

Why don't you use PositionGetDouble()  with POSITION_PROFIT  ?

 

Perhaps you should be using Select()  rather than OrderSelect() ? 

There you go knew I was stupid lol! thanks


Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2013.03.07 10:28  
BigAl:

There you go knew I was stupid lol! thanks 

Not stupid at all,  I now know the difference between Select() and OrderSelect() in mql5,  thanks for helping me learn  :-)
phi nuts
2184
phi nuts 2013.03.07 11:33  

That's from standard library.

Use MQL5 function PositionSelect  and then PositionGetDouble with POSITION_PROFIT identifier.

BigAl
489
BigAl 2013.03.07 14:46  
RaptorUK:
Not stupid at all,  I now know the difference between Select() and OrderSelect() in mql5,  thanks for helping me learn  :-)
Thanks again
BigAl
489
BigAl 2013.03.07 14:50  
BigAl:
Thanks again
phi.nuts:

That's from standard library.

Use MQL5 function PositionSelect  and then PositionGetDouble with POSITION_PROFIT identifier.

Thanks to you too phi.nuts - I am still finding the switch to MQL5 from 4 difficult - the documentation is not as clear as 4 - not enough examples and loads of what would appear to me as alternative ways of doing things. Thats why i keep getting it wrong
To add comments, please log in or register