How to gat AccountBalance of an specific time?

 
Is there any code, function or something which is able to return Account Balance of an specific time? For example at the beginning of the day.
 

count your current balance with your today profit

   
    double todayprofit=0;
    datetime Openday= iTime(Symbol(),PERIOD_D1,0); 
 
 for(int xx=OrdersHistoryTotal()-1;xx>=0;xx--)
 { if(!OrderSelect(xx,SELECT_BY_POS,MODE_HISTORY))continue;
   if(OrderCloseTime()<Openday)break;
   if(OrderType()<2)todayprofit+=OrderProfit()+OrderSwap()+OrderCommission(); 
 }  
 
 
farrokhfa: Is there any code, function or something which is able to return Account Balance of an specific time? For example at the beginning of the day.
Could EA Really Live By Order_History Alone? - MQL4 forum
 
WDholic:

count your current balance with your today profit

I tried this, but it does not work for me...

   Alert( "aaaaa1",TimeToStr(TimeCurrent()),AccountBalance() );

   Print( "1Time=",TimeToStr(TimeCurrent()),AccountBalance() );

 

I see no alerts with my values in,

What I was trying to do is to display my balance on a tick by tick where the current price of the instrument is printed at the top left of my screen...

 

GBPUSD,M15 1.15234 1.15756 1.52013 1.152320 

 
int OnInit()
  {

   HistorySelect(D'2024-02-27 00:00:00',TimeCurrent());
   int dealsTotal;
   dealsTotal = HistoryDealsTotal();
   ulong historyTicket;
   double totalProfit = 0;
   for(int i=0; i<dealsTotal; i++)
     {
      historyTicket= HistoryDealGetTicket(i);
      totalProfit+= HistoryDealGetDouble(historyTicket,DEAL_PROFIT);
      totalProfit+=HistoryDealGetDouble(historyTicket,DEAL_COMMISSION);
      totalProfit+=HistoryDealGetDouble(historyTicket,DEAL_SWAP);
     }
   double Balance_at_the_beginningOfDay; 
   Balance_at_the_beginningOfDay = AccountInfoDouble(ACCOUNT_BALANCE) - totalProfit;
   Print("total net profit : " + (string)NormalizeDouble(totalProfit,2));
   Print("your account balance at the beginning of day is : " + (string)NormalizeDouble(Balance_at_the_beginningOfDay,2));


   return(INIT_SUCCEEDED);

  }


my last transactions has done on ' '2024-02-27 '

use the code above to calculate Account Balance At The Beginnig of Day

Files:
1.jpg  13 kb
2.jpg  387 kb
3.jpg  22 kb
 
vahid basirat #:    use the code above to calculate Account Balance At The Beginnig of Day
  1. Why did you post your MT5 code in the MT4 forum?

  2. Do you really expect that people are still watching this thread after nine (9) years?
    Don't resurrect old threads without a very good reason. A lot has changed since Build 600 and Higher. (2014)

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

Reason: