OrderProfit() return value including Commission and Swap?

 

OrderProfit()  - This will return only Pips value or Final Profit/Loss after calculating swap and commission also.


Default Code :

double CalculateTradeFloating(int A_magic_0)
  {
   double CalculatePL= 0;
   for(int pos_12 = 0; pos_12 < OrdersTotal(); pos_12++)
     {
      OrderSelect(pos_12, SELECT_BY_POS, MODE_TRADES);
      if(OrderSymbol() != Symbol() || OrderType() > OP_SELL)
         continue;
      if(A_magic_0 == OrderMagicNumber())
         CalculatePL+= OrderProfit();
     }
   return (CalculatePL);
  }


Recently i founded in broker which charging Commission, P/L returning by this function is different than original P/L.


Should i try like this?

double CalculateTradeFloating(int A_magic_0)
  {
   double CalculatePL= 0;
   for(int pos_12 = 0; pos_12 < OrdersTotal(); pos_12++)
     {
      OrderSelect(pos_12, SELECT_BY_POS, MODE_TRADES);
      if(OrderSymbol() != Symbol() || OrderType() > OP_SELL)
         continue;
      if(A_magic_0 == OrderMagicNumber())
         CalculatePL+= OrderProfit() + OrderCommission() + OrderSwap();
     }
   return (CalculatePL);
  }


Should i have to use OrderProfit() + OrderCommission() + OrderSwap() or OrderProfit() is enough?

 
anuj71:

OrderProfit()  - This will return only Pips value or Final Profit/Loss after calculating swap and commission also.


Default Code :


Recently i founded in broker which charging Commission, P/L returning by this function is different than original P/L.


Should i try like this?


Should i have to use OrderProfit() + OrderCommission() + OrderSwap() or OrderProfit() is enough?

OrderProfit does not count commission and swap.
 
Yashar Seyyedin #:
OrderProfit does not count commission and swap.

So, this is best approach?

         CalculatePL+= OrderProfit() + OrderCommission() + OrderSwap();
 
anuj71 #:

So, this is best approach?

Yes
 

Total Profit is OrderProfit() + OrderSwap() + OrderCommission(). Some brokers don't use the Commission/Swap fields. Instead, they add balance entries. (Maybe related to Government required accounting/tax laws.)
          "balance" orders in account history - Day Trading Techniques - MQL4 programming forum (2017)

Broker History
FXCM
Commission - «TICKET»
Rollover - «TICKET»

>R/O - 1,000 EUR/USD @0.52

#«ticket»  N/A
OANDA
Balance update
Financing (Swap: One entry for all open orders.)
 
William Roeder #:
Total Profit is OrderProfit() + OrderSwap() + OrderCommission(). Some brokers don't use the Commission/Swap fields. Instead, they add balance entries. (Maybe related to Government required accounting/tax laws.)

Then, what is the best approach to calculate P/L. Can you provide me sample code


URL is broken. Can you provide correct URL

 
anuj71 #: URL is broken. Can you provide correct URL

One extra slash, missing quote. Try: "balance" orders in account history - Day Trading Techniques - MQL4 programming forum