Download MetaTrader 5
To add comments, please log in or register
Why to sell products in MetaTrader AppStore? Find that out from the article!
BigAl
487
BigAl 2013.03.29 11:46 

How do calculate the above:

For example, if I start by placing a trade of lets say 5 lots of EURUSD then on the in the toolbox under the trade tag I can see the order type, the price the order was placed at, the current  price & current P/L.

Now if I sell 0.01 lots of EURUSD I can see the lots change to 4.99 but the price that the 5 lot order was placed at changes to what I assume is arrived at by some sort of averaging algorithm - how do I calculate this new price?

Now I assume that having sold 0.01 lots, then the overall P/L stays as current price x lots * 100000. But how is the P/L of the sold 0.01 lots calculated? I assume this is the difference between the averaged price and the current price x lots x 100000, is this correct?

If I purchase addition lots what are the calculations then (assume the reverse?)

Finally, how do I get the averaged price returned to my EA?

I hope you can understand what I am asking

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
Alain Verleyen
Moderator
28701
Alain Verleyen 2013.03.29 13:03  
BigAl:

How do calculate the above:

For example, if I start by placing a trade of lets say 5 lots of EURUSD then on the in the toolbox under the trade tag I can see the order type, the price the order was placed at, the current  price & current P/L.

Now if I sell 0.01 lots of EURUSD I can see the lots change to 4.99 but the price that the 5 lot order was placed at changes to what I assume is arrived at by some sort of averaging algorithm - how do I calculate this new price?

Now I assume that having sold 0.01 lots, then the overall P/L stays as current price x lots * 100000. But how is the P/L of the sold 0.01 lots calculated? I assume this is the difference between the averaged price and the current price x lots x 100000, is this correct?

If I purchase addition lots what are the calculations then (assume the reverse?)

Finally, how do I get the averaged price returned to my EA?

I hope you can understand what I am asking

Read this and tell us if that help.
BigAl
487
BigAl 2013.03.30 07:37  
angevoyageur:
Read this and tell us if that help.
thats good, thanks
BigAl
487
BigAl 2013.03.31 08:42  
angevoyageur:
Read this and tell us if that help.
Thanks again but you can tell me if I can actually return the average price to my EA rather then keeping track of it myself.
Alain Verleyen
Moderator
28701
Alain Verleyen 2013.03.31 10:46  
BigAl:
Thanks again but you can tell me if I can actually return the average price to my EA rather then keeping track of it myself.
Sorry but I don't understand your question, maybe because of the time change in Europe ;-)
BigAl
487
BigAl 2013.04.02 15:33  
angevoyageur:
Sorry but I don't understand your question, maybe because of the time change in Europe ;-)
OK - The current price of a position is the average price of all the trades conducted on a single position (say EURUSD). that averaged price is displayed on the trades tab of the toolbox just to the right of the Volume. Is there a way of accessing this average price from an EA (something like myaveragedprice = EURUSDpositionaveragedprice) yes (lol) very clumsy example but I hope it helps explain what I am asking
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2013.04.02 15:40  
BigAl:
OK - The current price of a position is the average price of all the trades conducted on a single position (say EURUSD). that averaged price is displayed on the trades tab of the toolbox just to the right of the Volume. Is there a way of accessing this average price from an EA (something like myaveragedprice = EURUSDpositionaveragedprice) yes (lol) very clumsy example but I hope it helps explain what I am asking
You don't mean the current price,  that is Bid,  I assume you mean the averaged Position Open Price ?  Wouldn't you use PositionGetDouble()  with POSITION_PRICE_OPEN  don't forget to select the position first using  PositionSelect()
Alain Verleyen
Moderator
28701
Alain Verleyen 2013.04.02 18:39  
BigAl:
OK - The current price of a position is the average price of all the trades conducted on a single position (say EURUSD). that averaged price is displayed on the trades tab of the toolbox just to the right of the Volume. Is there a way of accessing this average price from an EA (something like myaveragedprice = EURUSDpositionaveragedprice) yes (lol) very clumsy example but I hope it helps explain what I am asking
Obviously you can access all the info seen on MT5 interface with MQL5. See RaptorUk answer.
BigAl
487
BigAl 2013.04.03 16:19  
RaptorUK:
You don't mean the current price,  that is Bid,  I assume you mean the averaged Position Open Price ?  Wouldn't you use PositionGetDouble()  with POSITION_PRICE_OPEN  don't forget to select the position first using  PositionSelect()
Thanks
BigAl
487
BigAl 2013.04.03 16:20  
angevoyageur:
Obviously you can access all the info seen on MT5 interface with MQL5. See RaptorUk answer.

Cheers

/
To add comments, please log in or register