This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community
Value of profit of open ordersBack to topics list |
|
Keris2112
2005.12.08 22:49
I've tried searching for this, but I can't find an answer....
Can somebody tell me how to get the total value of all currently open positions. If I understand correctly, AccountProfit() gives the total profit/loss for the account as a whole. I just want the total profit/loss of open positions. Can this be done, and if so, how? Thanks |
|
MichelB
2005.12.09 00:55
I've tried searching for this, but I can't find an answer.... Can somebody tell me how to get the total value of all currently open positions. If I understand correctly, AccountProfit() gives the total profit/loss for the account as a whole. I just want the total profit/loss of open positions. Can this be done, and if so, how? Thanks I am sure that AccountProfit() returns the profit of opened positions. Try it ! Put a print(AccountProfit()); somewhere and see what is printed... otherwise, do a loop to compute it :
double Profit = 0;
for(cnt = 0; cnt < OrdersTotal(); cnt ++)
{
if (!OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) continue;
Profit += OrderProfit();
}
|
|
Keris2112
2005.12.09 02:47
Thank you for your help. I'll try AccountProfit(). The method using the loop is great too. Even if AccountProfit() works, I'll be able to modify the loop code to do other things.
Thanks again. |
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets
