Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1515

 

Gentlemen, I have identified the cause. The problem is in the calculation of the balance, which is needed to allow for a day's output, and although this formula does not produce errors, it does not work.

   datetime TimeCheck_sb = StrToTime("1:00");

   if(TimeCurrent()==TimeCheck_sb)
     {
       sb1 = AccountBalance();
     }
// и это мне вы тут насоветовали на форуме!!!!!!


   далее там условие такое if(sb1 + sb1/100*LotRisk*(DayMultiplicatorProfit/100) > AccountBalance())
                               {

                                условие открытия ордера...

                                }

If you do it for fun, it works.

AccountBalance()>0

if you do it for fun, it doesn't work

sb1>0

double sb1; - declared if anything...


The question should be solved with

 sb1 = AccountBalance();
 
Порт-моне тв:

Gentlemen, I have identified the cause. The problem is in the calculation of the balance, which is needed to allow for a day's output, and although this formula does not produce errors, it does not work.

If you do it for fun, it works.

if you do it, it doesn't

double sb1; - is declared if anything...


Solve the issue with

   datetime TimeCheck_sb = StrToTime("1:00");

   if(TimeCurrent()==TimeCheck_sb)

it doesn't have to work every day... moreover, it's strange if it will work regularly at all

 
Maxim Kuznetsov:

it doesn't have to be triggered every day...in fact, it would be strange if it was triggered regularly at all

and how do i fix the balance at the beginning of the day?

 

Sorry, but I still don't get it - how to set KEY_TILDE to two events - Highlight and Unselect. I get either simultaneous triggering and displaying a message in terminal or only this default option. How can a dumbass explain how to do it?

if(id==CHARTEVENT_KEYDOWN)
     {
      switch(int(lparam))
        {
         case KEY_TILDE:
            ObjectSetInteger(0,"RectLabel",OBJPROP_SELECTABLE,true);
            ObjectSetInteger(0,"RectLabel",OBJPROP_SELECTED,true);
            Print("Выделить!");
            break;
            
            default:
            ObjectSetInteger(0,"RectLabel",OBJPROP_SELECTABLE,false);
            ObjectSetInteger(0,"RectLabel",OBJPROP_SELECTED,false);
            Print("Отменить выделение!");
            break;
        }
        
     }
 
DYM:

Sorry, but I still don't get it - how to set KEY_TILDE to two events - Highlight and Unselect. I get either simultaneous triggering and displaying a message in terminal or only this default option. How can a brainless person explain how to do it?

Detected event - check status... If it's selected - deselect. Otherwise it is selected.

 
DYM:

Sorry, but I still don't get it - how to set KEY_TILDE to two events - Highlight and Unselect. I get either simultaneous triggering and displaying a message in terminal or only this default option. How can a dumbass explain how to do it?


//+------------------------------------------------------------------+
if(id==CHARTEVENT_KEYDOWN)
     {
      switch(int(lparam))
        {
         case KEY_TILDE: 
         TILDE(); 
         break;
        }
     }
//+------------------------------------------------------------------+
void TILDE()
  {
   if(ObjectGetInteger(0,"RectLabel",OBJPROP_SELECTABLE)==false)
     {
      ObjectSetInteger(0,"RectLabel",OBJPROP_SELECTABLE,true);
      ObjectSetInteger(0,"RectLabel",OBJPROP_SELECTED,true);
      Print("Выделить!");
     }
   else
     {
      ObjectSetInteger(0,"RectLabel",OBJPROP_SELECTABLE,false);
      ObjectSetInteger(0,"RectLabel",OBJPROP_SELECTED,false);
      Print("Отменить выделение!");
     }
  }
 
Порт-моне тв:

and how do i fix the balance value at the beginning of the day then?

does anyone have any ideas?

 
Порт-моне тв:

Anyone have any thoughts?

   if(AccountBalance()>0)
     {
      sb1 = AccountBalance()-DayProfit();
     }
................

//+--------------------------------------------------------------------------------------------------------------------+
//|  Суммарный профит в валюте депозита закрытых с определённой даты позиций                                           |
//+--------------------------------------------------------------------------------------------------------------------+
double DayProfit()
  { double p = 0; datetime st=StrToTime("1:00");
   for(int pos=OrdersHistoryTotal()-1;pos>=0;pos--)
     {
      if(OrderSelect(pos,SELECT_BY_POS,MODE_HISTORY)==true)
        {
         if(OrderCloseTime()>=st){p+=OrderProfit()+OrderSwap()+OrderCommission();}
        }
     }
   return(p);
  }
//+--------------------------------------------------------------------------------------------------------------------+
 
MakarFX:


I don't know how to thank you...except to say thank you so much for your help. I'll try not to bother you anymore :)
 
Порт-моне тв:

anyone have any thoughts?

catch the change of the day and calculate the balance value at that moment.

It's not for nothing that they said "take the right indicator" - it won't fit into a couple of lines of code. It's quite a capacious algorithm.

catching the day change is easy, "the known day number now is not equal to the day number before", but further it is difficult

Reason: