financing fee

 

Hi 

Does anyone know how to calculate in EA the financing fees charged by the broker?

I wrote this code to calculate daily profit (see below).  It works fine.  Except it does not include
the broker's daily financing fee.   That's because the broker will list the fee under the Profit heading 
as a loss (example: -6.89) and the date of the transaction in the open order time field.

If I include the OrderOpenTime() formula in my code (see below) the result is wrong as it will include
ALL orders that were opened on that day.

Any suggestions anyone?

Thanks

Lode

double DailyProfit()
{
double profit = 0;
int i,hstTotal=OrdersHistoryTotal();
  for(i=0;i<hstTotal;i++)
    {
     if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==TRUE)
       {
         if(OrderType()>1) continue;
         if(TimeToStr(TimeCurrent(),TIME_DATE) == TimeToStr(OrderCloseTime(),TIME_DATE))
         {
            profit += OrderProfit() + OrderSwap() + OrderCommission();
         }       
       }
    }
   return(profit);
}
 

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.)
          "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.)

Hello William;

Thanks for the response.

I got the formula ( Total Profit is OrderProfit() + OrderSwap() + OrderCommission()); so no problem there.  Oanda is my broker and you are correct they add balance entries.

My problem is they add this entry under the "Type" heading in the history log (see image below) but the OrderType() does not provide for a custom search such as the word
"balance".  So that's my dilemma.  How can I auto-calculate the finance charge and subtract it from my overall profit?

Thank you again for your answer.  I do appreciate your time.

Lode