Open P&L for BUY Trades or Sell Trades ONLY per pair??
5 replies
JS17
7 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) ???????
tomas262
7 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?
JS17
7 years ago #140981
Do you need a function to return open P/L for all buy orders opened in a specific pair?
Yes please 🙂
tomas262
7 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; }
JS17
7 years ago #141021
tomas262
7 years ago #141022
Ops, sorry, it is already attached 🙂
Viewing 5 replies - 1 through 5 (of 5 total)