Current profit on an open position

 

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
 
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() ? 

 
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


 
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  :-)
 

That's from standard library.

Use MQL5 function PositionSelect  and then PositionGetDouble with POSITION_PROFIT identifier.

 
RaptorUK:
Not stupid at all,  I now know the difference between Select() and OrderSelect() in mql5,  thanks for helping me learn  :-)
Thanks again
 
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
Reason: