Open P&L for BUY Trades or Sell Trades ONLY per pair??
5 replies
JS17
9 years ago #116167
Hi all,
As the title says, How do I get for example the open P&L for BUY only trades per pair(symbol) ???????
0
Tomas Matejka
9 years ago #140975
Hello,
with the “Open PL” function you always specify the magic number so this function always return open PL for a specific order.
Do you need a function to return open P/L for all buy orders opened in a specific pair?
0
JS17
9 years ago #140981
Do you need a function to return open P/L for all buy orders opened in a specific pair?
Yes please 🙂
0
Tomas Matejka
9 years ago #141018
Hello,
Add this into EA Wizard / code / CustomFunctions.mq4 file. Then you can use it in Wizard as it is shown in example attached
float sumProfitLong(string symbolString) {
float totalLongProfit = 0;
for(int i=OrdersTotal()-1; i>=0; i--) {
if (OrderSelect(i,SELECT_BY_POS)==true) {
if (OrderType() == OP_BUY && OrderSymbol() == symbolString) {
totalLongProfit += OrderProfit();
}
}
}
return totalLongProfit;
}
0
JS17
9 years ago #141021
Thankyou
which example?
No example attached
0
Tomas Matejka
9 years ago #141022
Ops, sorry, it is already attached 🙂
0
Viewing 5 replies - 1 through 5 (of 5 total)