How to calculate average price for open orders - page 3

 
Fernando Carreiro #:

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

If you can do a complete file, I will give you money:D

 
Hoang Minh Trong #: If you can do a complete file, I will give you money:D

Not interested! If you want to pay someone then place a request in the Freelance section. Someone else will do it for you, but not me!

 
Fernando Carreiro #:

Not interested! If you want to pay someone then place a request in the Freelance section. Someone else will do it for you, but not me!

Ok thank you. Anyway, I think you can't afford to write this:))

 
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

If buy lots = sell lots how do you calculate? Because it will be division by zero.

 
Theresia Yovitha Herwanda #: If buy lots = sell lots how do you calculate? Because it will be division by zero.

Then they cancel each out and you are only paying the spread for the total volume.

 
Theresia Yovitha Herwanda #:

If buy lots = sell lots how do you calculate? Because it will be division by zero.

Buy lots is plus, sell is negitive;. compute Lots weighted avere price. #3
 
Great job, congratulations.

however there is one aspect missing that is interesting ... if I wanted to add an order and keep the risk unchanged, i.e. reduce the stop and target pips ..... how do I also transform any stop loss and take profit?
 
Sabino Martiradonna #:
Great job, congratulations.

however there is one aspect missing that is interesting ... if I wanted to add an order and keep the risk unchanged, i.e. reduce the stop and target pips ..... how do I also transform any stop loss and take profit?

the calc/math does not change for volume weighted. If you increase the lot of the new trade to big enuf, then, the average price will get closer to current price.

 

Thanks to everyone, but I'll explain the situation better.

It's a NETTING account. My system add orders for mediating the position. The stop and target points are predefined by money management. !! es: 100 sl points and 100 tp points.

We know that in the netting account there is only one position, which in this situation increases the assigned lots, as I add positions (if of the same sign)

The problem is this: when I add a position with predefined stop and target, (100 and 100 pips), it happens that the resulting position has an "open price" mediated correctly but the stop and target pips do NOT coincide with those corresponding to my opening. es: I see 80 and 120 !!!! and not 100 and 100 .... how did I set the parameter in the "send order" function !!!

.. And therefore I can't keep constant the "distance" at 100 sl and 100 tp ....

how can I solve it?

Ciao

 
Sabino Martiradonna #:


Ciao

Then, your issue is very different to the original op of this thread. Open your own thread with your question. However, I think that you will be hard to get a sure answer since most traders have hedging accounts. However, i am now curious to find the answer. i will do some searching for the answer, as you should be doing. Maybe search codbase and marketplace with search terms "netting average"?????