@biez6900 How to operate specifically? Can you be more detailed? I happen to need this too, thank you dear friend
Unsolved Calculate Weight Average Open Price
-
Hi,
I would like to calculate weight average open price of active orders. For Example, there are 2 active orders. 1st Order have open price at 1.0000 with 1 LOT.
2nd order have open price at 1.5000 with 4 LOT. The weight average open price of these 2 orders will be 1.4000.
Please suggest me that how can I code EA to calculate this value.Regards,
-
I surrender at this. It's not impossible, but the solution will be ugly I think. But why do you need this? In "Trailing stop (group of trades)" this is something that happens in the block. If you want it for something else, maybe there is a better alternative. I think that, because I don't remember someone asking the same question before.
- 6 years later
-
@fxdreema Hello Sir I want to calculate the average price of open buy trades so that i can set Tp of all open trades.
I use formulas for calculation of avg open price but its working wrong when a trade is closeKindly make a block for Average price calculator. Or
Calculate a weighted average block.Thanks.
-
@muhawat I think this is what you want to do, you will have to multply SL value depending on asset, (not worked out how to do it on auto), you can copy to do same with TP, this will give you the current price if stop is hit. https://fxdreema.com/shared/WRFjFb2Hd
- about a year later
-
Hi @muhawat
I think I had a similar question and I played around today and manage to do this. https://fxdreema.com/shared/1rWwBHYWb
It calculates the average price of all open trades so that you can get a BreakEven price. I hope this helps. -
Unfortunately after testing thoroughly I found that the values returned is not correct. I'll continue trying and post the update here asap.
- 11 months later
-
//| Fonction pour calculer le prix moyen pondéré par le volume | //+------------------------------------------------------------------+ double CalculateVolumeWeightedPrice() { double totalVolume = 0.0; // Volume total des transactions double totalValue = 0.0; // Valeur totale pondérée par le volume // Parcourir toutes les transactions de la position actuelle for (int i = 0; i < PositionsTotal(); i++) { // Sélectionner la position if (PositionGetTicket(i)) { double volume = PositionGetDouble(POSITION_VOLUME); // Volume de la transaction double price = PositionGetDouble(POSITION_PRICE_OPEN); // Prix d'ouverture de la transaction // Ajouter au volume total et à la valeur totale totalVolume += volume; totalValue += volume * price; } } // Éviter une division par zéro if (totalVolume == 0.0) { return 0.0; } // Calculer le prix moyen pondéré par le volume double volumeWeightedPrice = totalValue / totalVolume; return volumeWeightedPrice; }
-
`thanks deepseek, create a function here : https://fxdreema.com/studio and use that
- 4 months later
-
@biez6900 How to operate specifically? Can you be more detailed? I happen to need this too, thank you dear friend