Download MetaTrader 5

Value of a position

To add comments, please log in or register
Interested in Signals activity? Come and track!
BigAl
489
BigAl 2012.11.21 20:31 

I am a newbe trying to get to grips with MT5. Please can someone answer my question below.

As each currency pair can only have one position is there a command/function to obtain the $value (assuming the base currency is USD) of that position or do I have to calculate it for myself?

I cant find anything in the documentation but someone told me there is such a function.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Symbol Properties - Documentation on MQL5
kaloian kaloianov
445
kaloian kaloianov 2012.11.21 20:38  
BigAl:

I am a newbe trying to get to grips with MT5. Please can someone answer my question below.

As each currency pair can only have one position is there a command/function to obtain the $value (assuming the base currency is USD) of that position or do I have to calculate it for myself?

I cant find anything in the documentation but someone told me there is such a function.

hi, i think that you are looking for that:

 


double somvariable=PositionGetDouble(POSITION_VOLUME); 

Heinz Traub
314
Heinz Traub 2012.11.21 21:05  

I assume that by value you mean profit:

if(PositionSelect("USDJPY"))
{
    double value = PositionGetDouble(POSITION_PROFIT);
}

BigAl
489
BigAl 2012.11.21 21:28  
TripleHeinz:

I assume that by value you mean profit:

if(PositionSelect("USDJPY"))
{
    double value = PositionGetDouble(POSITION_PROFIT);
}

Thanks for answers so far but what I actually want is the current value of the trade. That is lets say I purchased 1 lot of a pair that costs me 12000 xxs (EUR, USD or whatever). At a later time I would like to know the current value of that trade in xxs. the value could now be higher or lower or the same. I do not want the profit or lot size just the current total value. without having to calculate it.

Rogerio Figurelli
Moderator
39504
Rogerio Figurelli 2012.11.22 01:36  
Note that unlike a stock trade, where you pay to enter and again to exit, in a Forex position you will be charged by spreads after you exit and POSITION_PROFIT, as TripleHeinz suggest, looks good to get a realtime position as you asked.
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
phi nuts
2184
phi nuts 2012.11.22 02:42  
Did you mean, the cost of opening a position/order ?. If it is, it's called Margin required. Use this https://www.mql5.com/en/docs/trading/ordercalcmargin also read  this  https://www.mql5.com/en/forum/7418#comment_295412 and read the whole topic if you like.
Documentation on MQL5: Trade Functions / OrderCalcMargin
Documentation on MQL5: Trade Functions / OrderCalcMargin
  • www.mql5.com
Trade Functions / OrderCalcMargin - Documentation on MQL5
BigAl
489
BigAl 2012.11.22 10:34  
phi.nuts:
Did you mean, the cost of opening a position/order ?. If it is, it's called Margin required. Use this https://www.mql5.com/en/docs/trading/ordercalcmargin also read  this  https://www.mql5.com/en/forum/7418#comment_295412 and read the whole topic if you like.
None of these - I want to know if there is a function I can use to get this ----- myrequest.price * myrequest.volume * 100000 or do I have to do this calc and then mess about to get correct decimal places etc
phi nuts
2184
phi nuts 2012.11.22 11:02  
BigAl 2012.11.21 21:28 

Thanks for answers so far but what I actually want is the current value of the trade. That is lets say I purchased 1 lot of a pair that costs me 12000 xxs (EUR, USD or whatever). At a later time I would like to know the current value of that trade in xxs. the value could now be higher or lower or the same. I do not want the profit or lot size just the current total value. without having to calculate it

BigAl 2012.11.22 10:34 
None of these - I want to know if there is a function I can use to get this ----- myrequest.price * myrequest.volume * 100000 or do I have to do this calc and then mess about to get correct decimal places etc

BigAl,

Correct and give me example if I'm dead wrong.

1. Say you buy I.05 lots of EURUSD at 1.23435 - what you want to know is how much that cost you ?, Am I correct here ?

2. Later when this 1.05 lots EURUSD rise up to 1.30056, you also want to know how much does it cost you now at this price. Am I correct here too ?

BigAl
489
BigAl 2012.11.26 00:54  

I have resolved my problem thanks for your help


Gustavo Semiz
950
Gustavo Semiz 2013.01.21 12:27  
BigAl:

I have resolved my problem thanks for your help


BigAl

How to do to resolve the problem?, i have the same situation.

thanks

To add comments, please log in or register