I will write an advisor free of charge - page 78

 
Vitali_Leto:
That would be great.

Use the function:

double GetProfitForDay(int nd) {
   double profit = 0;
   for (int i = 0; i < OrdersHistoryTotal(); i++) {
      if (!(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))) break;
      if (OrderSymbol() == Symbol())
         if (OrderCloseTime() >= iTime(Symbol(), PERIOD_D1, nd) && OrderCloseTime() < iTime(Symbol(), PERIOD_D1, nd) + 86400) profit += OrderProfit() + OrderSwap() + OrderCommission();
   }
   return (profit);
}

nd=0 - current day, nd=1 - yesterday, etc.

 
Maksim Sovenko:

Use the function:

nd=0 - current day, nd=1 - yesterday, etc.

Everything is just fine, but my knowledge in this direction is very lame so far. Please tell me how to do it

 
I changed this part of the code, 4 errors come up
 
Vitali_Leto:
I have changed this part of code and 4 errors appear
EditCreate(0,"EARNED",0,X,Y+84,140,20,0,Menu[4]+DoubleToString(GetProfit(),2),"Arial",8,ALIGN_CENTER,true,txtcolor,pnlcolor,pnlcolor);

TheGetProfit() function is currently calledwithout argument.

You insert the attached function and give the argumentGetProfitForDay(0)

Of course, this must be done throughout the code where this function is called

 

Also, the symbol check is likely to be superfluous and should be removed:

if (OrderSymbol() == Symbol())
and replaceSymbol() withOrderSymbol() in the following condition
 
Maksim Sovenko:

TheGetProfit() function is currently calledwithout argument.

You insert the attached function and give the argumentGetProfitForDay(0)

Of course, this should be done throughout the code where this function is called

GetProfitForDay' - wrong parameters count CurrentInfo.mq4 40 70


 
Vitali_Leto:

'GetProfitForDay' - wrong parameters count CurrentInfo.mq4 40 70


show how you call this function

 
Got it. How do I make it so that both today and the total are shown at once?
 
I forgot to prescribe 0
 
Something's counting wrong
Files: