How to calculate average price for open orders

 

Hi all, I need an indicator for calculate avarage price for all open order, incluse Buy and Sell. I have an Indi for MT4. But MT5 I haven't.

Can Someoe help me, Please!

Simply calculate

W: lot size

P: entry

For Buy is +
For Sell is -

Ex:

Buy 1lot at 1900
Buy 1lot at 1910

Sell 5 lot at 1890

>>> Averrage is Sell 3 lot at 1880

We can set Sl and TP at Price 1880 for zero profit.

 




 
Hoang Minh Trong:

Hi all, I need an indicator for calculate avarage price for all open order, incluse Buy and Sell. I have an Indi for MT4. But MT5 I haven't.

Can Someoe help me, Please!

Simply calculate

W: lot size

P: entry

For Buy is +
For Sell is -

Ex:

Buy 1lot at 1900
Buy 1lot at 1910

Sell 5 lot at 1890

>>> Averrage is Sell 3 lot at 1880

We can set Sl and TP at Price 1880 for zero profit.

 




Mean breakeven? Huh, that's complex for both directions.

Maybe if you get Long Breakeven and Short Breakeven separately, then you can calculate your Breakeven with their respective total volumes.

 
David Diez #:

Mean breakeven? Huh, that's complex for both directions.

Maybe if you get Long Breakeven and Short Breakeven separately, then you can calculate your Breakeven with their respective total volumes.

I dont know about MQL5:D

But I can use Excel for calculate.

Price Average is: For Lot Buy count positive,Lot Sell count negative

((Price1*Lot1 + Price2*lot2 +....)/(lot1+lot2...)=Price average

Lot averagre = lot 1+ lot2+...lotn

Ex:

Buy 1lot at 1900
Buy 1lot at 1910

Sell 5 lot at 1890

(1900*1+1910*1+1890*-5)/(1+1-5)=-1880

Lot is 1+1-5= -3

>>>> Sell 3 lot at 1880

Can you Help me, plssss

 
Hoang Minh Trong: Can Someoe help me, Please!

Help you with what? You already know: Lots Weighted Average Price = ∑  op(i) × lot(i) ÷ ∑ lot(i). This is the break even price of all orders combined.
          OrderOpenPrice question . - MQL4 programming forum (2017)
          looking for sample code on how to calculate the price BE for a few Buy and Sell orders simultaneously - Pips - MQL4 programming forum (2016)

Use +Lots for buys and -Lots for sells.

 
William Roeder #:

Help you with what? You alrady know: Lots Weighted Average Price = ∑ op (i) × lot (i) ÷ ∑ lot (i) . This is the break even price of all orders combined.

Use +Lots for buys and -Lots for sells.

Thank you, I know how to count but I dont know code this. Can you help me. I think it so easy for Pro, but not me :((

 
William Roeder #:

Help you with what? You already know: Lots Weighted Average Price = ∑  op(i) × lot(i) ÷ ∑ lot(i). This is the break even price of all orders combined.
          OrderOpenPrice question . - MQL4 programming forum (2017)
          looking for sample code on how to calculate the price BE for a few Buy and Sell orders simultaneously - Pips - MQL4 programming forum (2016)

Use +Lots for buys and -Lots for sells.

I just need complete code for count  Lots Weighted Average and  Price average.

Show this on chart and draw a line at this price.

 
William Roeder #:

Help you with what? You already know: Lots Weighted Average Price = ∑  op(i) × lot(i) ÷ ∑ lot(i). This is the break even price of all orders combined.
          OrderOpenPrice question . - MQL4 programming forum (2017)
          looking for sample code on how to calculate the price BE for a few Buy and Sell orders simultaneously - Pips - MQL4 programming forum (2016)

Use +Lots for buys and -Lots for sells.

Love you. Can you help my a bit :(

 
Hoang Minh Trong #:

I dont know about MQL5:D

But I can use Excel for calculate.

Price Average is: For Lot Buy count positive,Lot Sell count negative

((Price1*Lot1 + Price2*lot2 +....)/(lot1+lot2...)=Price average

Lot averagre = lot 1+ lot2+...lotn

Ex:

Buy 1lot at 1900
Buy 1lot at 1910

Sell 5 lot at 1890

(1900*1+1910*1+1890*-5)/(1+1-5)=-1880

Lot is 1+1-5= -3

>>>> Sell 3 lot at 1880

Can you Help me, plssss

There's no negative lot, I was right.


 
David Diez #:

There's no negative lot, I was right.


Hehe. You right with BE Buy or BE Sell only.

If You hedge, You have Buy and Sell at a time.

Ex: 

Buy 1lot at 1900
Buy 1lot at 1910

Sell 5 lot at 1890

Where your BE of 3 order?
 

Forum on trading, automated trading systems and testing trading strategies

Average the entry price of the open trades

Fernando Carreiro, 2021.06.19 12:47

Please note that if your orders have different volumes (lots) and you are trying to calculate the net open price (that will be equivalent to a single order for the entire batch), then you have to apply the following calculations:


Forum on trading, automated trading systems and testing trading strategies

Any great idea about HEDGING positions welcome here

Fernando Carreiro, 2018.09.17 21:17

For those of you that want to learn to see the "light" and not fall into the trap of "hedging" and Grid strategies, here is the basic math:

How to Calculate the Net Resulting Equivalent Order:


Learn to do your research properly! Do not be blinded by false promises. Do the math!

 
Fernando Carreiro #:

I know how to cal. But I dont know how to code this :(