Michael Gold:
There are plenty of codes in this forum that you could have fixed your issue if you had only read 1 of them. The line you already suspect is the reason it will not work. And please follow the rules for posting in the forum! Use the src button when posting code, or you wont get any replies from this point (punn intended) haha
there is a function
https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties
in this webpage you will find position_profit
so if you calculate the total for all positions - you will be very near your total
![Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Position Properties Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Position Properties](https://c.mql5.com/36/84/documentation-on-mql5-constants.png)
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Position Properties
- www.mql5.com
Execution of trade operations results in the opening of a position, changing of its volume and/or direction, or its disappearance. Trade operations...
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi all,
I have been struggling in figuring out how to calculate unrealized net/gross profits for my current account. In other trading platforms there is a property of UnrealizedGrossProfit and UnrealizedNetProfit on the Account object itself. If this does not exist, can you do something like loop through open orders?
double TotalProfit()
{
double totalUnrealizedProfit =
for(int iPos=OrdersTotal()-1; iPos>=0; iPos--)
{//loop end to beginning
if(OrderSelect(iPos)== true) // not sure this works!
{//we found a ticket number
totalUnrealizedProfit += OrderProfit()+OrderSwap()+OrderCommission()); // these functions don't exist!
}
}
return(0.00);
} */