How to calculate average price for open orders - page 2

 
Hoang Minh Trong #:

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?

Should be around 1881.

 
David Diez #:

Should be around 1881.

Yes. I love you so much if you can help me build a code for this indicator. Draw a line for this price

 

Hoang Minh Trong #:

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 :((

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

Since you did not show your coding attempt at it, we are not able to guide you with your code.

If you want a complete solution for Indicator code, then you will have to hire someone in the Freelance section to do it for you.

Please note, that it is not EASY or QUICK for the "pros" — "Is it easy (or difficult) to …?"

Is it easy (or difficult) to …?
Is it easy (or difficult) to …?
  • 2017.08.30
  • www.mql5.com
This post could be considered a “rant”, but I would like to take the opportunity to relay to those that ask similar questions, the difficulty invol...
 
Fernando Carreiro #:

Since you did not show your coding attempt at it, we are not able to guide you with your code.

If you want a complete solution for Indicator code, then you will have to hire someone in the Freelance section to do it for you.

Please note, that it is not EASY or QUICK for the "pros" — "Is it easy (or difficult) to …?"

Haizz. Always is money! A few click can help someone happy but =.=!

 
Hoang Minh Trong #: Haizz. Always is money! A few click can help someone happy but =.=!

Haizz. Always is free code! A few dollars  can can help someone happy but =.=!

 
Fernando Carreiro #:

Haizz. Always is free code! A few dollars  can can help someone happy but =.=!

Lol, Dont pls rich man

 
in_orders_loop_sum:
 total_buy += OrderOpenPrice() * OrderLots();   // example: $1 * 0.1 lots + $2 * 0.1 lots = 0.3 (for two orders)     
 total_lots_buy += OrderLots();                 // example =0.2 lots total


double total_buy  = NormalizeDouble(total_buy / total_lots_buy, _Digits);            // calculate break even price. example: .3 / .2 = $1.50 breakeven price


A simple example is given in the comments.  Try a real example with real prices.

Basically it's just a normal average with the lot sizes factored in.

Note: this is not meant to be a whole program to compile, just simple a math example.
 
maximo # :


A simple example is given in the comments.  Try a real example with real prices.

Basically it's just a normal average with the lot sizes factored in.

You showed the wrong code: in MQL5 your example will not compile. You are on the MQL5 forum and the MQL5 language is discussed here.

 
Hoang Minh Trong #:

Yes. I love you so much if you can help me build a code for this indicator. Draw a line for this price

Ok, I'm not done with drawing but I got your solution: use negative lots (lol).


 
David Diez #:

Ok, I'm not done with drawing but I got your solution: use negative lots (lol).


It's so easy with Excel. Iam noob with MQL5 Code.

I have MT4 version. Huhu


<ex4 file deleted>
Reason: