# Value of a position

499

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
• www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Symbol Properties - Documentation on MQL5
443

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

314

I assume that by value you mean profit:

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

499

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.

Moderator
45008

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
• www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Position Properties - Documentation on MQL5
2181

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
• www.mql5.com
Trade Functions / OrderCalcMargin - Documentation on MQL5
499

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
2181

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 ?

499

I have resolved my problem thanks for your help

960

BigAl:

I have resolved my problem thanks for your help

BigAl

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

thanks