How To Calculate Position Prices of Multiple Orders ?

 

Hi all,

let's say, i made multipe transaction below:

 Buy 500,000 AUDUSD at 1.03756

 Buy 500,000 AUDUSD at 1.03726

 Buy 1,000,000 AUDUSD at 1.03856

 Buy 500,000 AUDUSD at 1.02362

 Buy 100,000 AUDUSD at 1.00192

My total position is now: 2,600,000 . How can i calculate what average price for this position. what formula can i use?


Thanks

Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants
  • www.mql5.com
Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants - Documentation on MQL5
 

(5 * 1.03756 + 5 * 1.03726 + 10 * 1.03856 + 5 * 1.02362 + 1 * 1.00192) / 26 = ~1.03384

The general formula is:

(Vol1 * Price1 + Vol2 * Price2 + ... + VolN * PriceN) / Sum(Vol)

 

Thanks :)