Download MetaTrader 5

Current profit on an open position

To add comments, please log in or register
BigAl
489
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

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
18025
Simon Gniadkowski  
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  
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
18025
Simon Gniadkowski  
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
2181
phi nuts  

That's from standard library.

Use MQL5 function PositionSelect  and then PositionGetDouble with POSITION_PROFIT identifier.

BigAl
489
BigAl  
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  
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