Finding average price of multiple trades with different entry price and lots considering swaps and commissions

Finding average price of multiple trades with different entry price and lots considering swaps and commissions

Manage alerts

Loading saved threads...

Aliko Aliko · External communityPost link
External question — Stack Overflow Stack Exchange Author: Aliko Aliko Original post: https://stackoverflow.com/questions/70919433 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I got this Mql4 code to find the average price. How can I add Swaps and commission to get the true break even price double lotsAndPrices(int magic, int orderType) { double lotsByPrice = 0; double orderLots = 0; for (int i = OrdersTotal() - 1; i >= 0; i--) { Sleep(1); if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol() == Symbol() && orderType == OrderType() && magic == OrderMagicNumber() ) { lotsByPrice += OrderOpenPrice() * OrderLots(); orderLots += OrderLots(); } } } if (orderLots > 0.0) lotsByPrice = NormalizeDouble(lotsByPrice / orderLots, Digits); return (lotsByPrice); }
Quote
Report
Yasin İPEK · External communityPost link
External answer — Stack Overflow Stack Exchange Author: Yasin İPEK Original post: https://stackoverflow.com/a/71525245 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. lotsByPrice += (OrderOpenPrice() * OrderLots()) + OrderCommission() + OrderSwap();
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External answer — Stack Overflow Stack Exchange Author: Yasin İPEK Source score (net votes, not local likes): -1 Original post: https://stackoverflow.com/a/71525245 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. lotsByPrice += (OrderOpenPrice() * OrderLots()) + OrderCommission() + OrderSwap();

Cancel quote

Checking account access…