- Sell Trade is opening and Closing on Entry
- Open Trade on New Bar
- basic question : Exit on close

86

mark692

hi guys its my first time coding mql4 and im still practicing. I have a problem on my project, I have 10 open trades on buy. i want to get the average of my entry price on buy, is that possible?

- Sell Trade is opening and Closing on Entry
- Open Trade on New Bar
- basic question : Exit on close

Moderator

31778

86

Add all the entry prices together.

Divide by 10.

Moderator

31778

double total=0; for(int x=OrdersTotal()-1; x>=0; x--) { if(OrderSelect(x,SELECT_BY_POS)) total+=OrderOpenPrice(); }

86

Moderator

31778

7121

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:

:

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

86

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:

7121

Well, it does require that you have some understanding of mathematics and its notation, in order to understand it. In essence:

- You first sum the volume of all open positions (That is the first calculation for "Net Total Volume").
- Then you sum the product of the open price and the volume of each position (that is to multiply the open price and volume for each position, and then sum it all up)
- You then take the sum in step 2 and divide it by the sum of step one. That will give you the "Net Mean Opening Price".

You can apply the same logic in the calculation of the "Net Mean Closing Price" (or the S/L or the T/P).

For the "Net Mean Profit or Loss", subtract the "Net Mean Opening Price" (step 3) from the "Net Mean Closing Price", then multiple by the "Net Total Volume" (step 1).

86

Well, it does require that you have some understanding of mathematics and its notation, in order to understand it. In essence:

- You first sum the volume of all open positions (That is the first calculation for "Net Total Volume").
- Then you sum the product of the open price and the volume of each position (that is to multiply the open price and volume for each position, and then sum it all up)
- You then take the sum in step 2 and divide it by the sum of step one. That will give you the "Net Mean Opening Price".

You can apply the same logic in the calculation of the "Net Mean Closing Price" (or the S/L or the T/P).

For the "Net Mean Profit or Loss", subtract the "Net Mean Opening Price" (step 3) from the "Net Mean Closing Price", then multiple by the "Net Total Volume" (step 1).

Sir Fernando is this what you mean volume? is that the lotsize?

im not good in english sorry

7121

Yes! Order "Volume" is measured it "Lots"!

The word "Mean" is equivalent to "Average"!

You are missing trading opportunities:

- Free trading apps
- Free Forex VPS for 24 hours
- Over 8,000 signals for copying
- Economic news for exploring financial markets

Registration
Log in

You agree to website policy and terms of use

If you do not have an account, please register