Calculating Unrealized Profit for the account

 

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);

   }  */

 
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

Reason: