Confused about simple net position calculation

 
Hi,

I am surprised that I do not come to a simple algorithm to obtain the net price of a hedge position.

e.g. 2 diffrent EAs, one for long-trades and one for short-trades:

[EURUSD] Open positions:

Buy 3.0 lots@1.3515
1.0 lot@1.3525

Sell -6.5 lots@1.3540
-1.0 lot@1.3538

Totally (-6.5-1) + 3 + 1 = -3,5 lots short, but whats the average-price for this position?

We have 4 lots long positions with an average price @ 1.3517 and 7.5 lots short at 1.35397.


-3.5 lots@??? 1,35318?

I have no plan, with only one direction, it is not a problem, but both directions at the same time
with different sizes...


Many thanks for suggestions.



Warm Regards
 
shck:

Buy 3.0 lots@1.3515
1.0 lot@1.3525

Sell -6.5 lots@1.3540
-1.0 lot@1.3538

Totally (-6.5-1) + 3 + 1 = -3,5 lots short, but whats the average-price for this position?

Lots weighted price. (3*1.3515 + 1*1.3525 - 6.5*1.3540 - 1*1.3538)/(-3.5)= 1.35651
 
Ok thanks, was a logical error of thinking :-X, because of the long positions is the average price higher than the highest trade price. Strange but brilliant, thank you.