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
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 ;-)
- www.mql5.com
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
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()
Obviously you can access all the info seen on MT5 interface with MQL5. See RaptorUk answer.
Cheers
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
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