[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 415

 

Punish him, put him in the corner. :)

And in essence - keep it simple, the phrasing is so constructed that you can break your brain and not understand what you're trying to do. No one knows what he has "learned" from you before.

 
Shniperson:
Gentlemen, how to "train" an EA not to trade at night ? I.e. terminal time between 23 and 02 hours (GMT)... Hour()>=2&Hour()<=23 did not help...

extern int bh = 0; // час начала
extern int bm = 0; // минута начала
extern int eh = 23;// час окончания
extern int em = 2; // минута окончания

int start()
{
   if(TradeTime() && Ваши условия входа) OrderSend(...);
}

bool TradeTime()
  { 
   int TimeNow = 60 * Hour() + Minute();   
   if (60 * bh + bm < TimeNow && TimeNow < 60 * eh + em) return (true);
   return (false);
  }
 

Здравствуйте всем. У меня МТ4 (демо) не связывается с сервером, даже не пытается. Постоянно горит надпись "нет связи". Пробовал "просканировать серверы" - не помогает.

 
Katso:


Is there a proxy on the way?
 
Vinin:

No
 
int start()                         
  {
//--------------------------------------------------------------------
   int
   S1,S2,                                                                 //S1 и S2 площадя следущего и предыдущего прямоугольников соответственно 
   j;                                                                     //значения стороны
//--------------------------------------------------------------------
   for( j=499, int i=1; i<500; i++,j--)                                   //последовательный перебор значений площади
      {
       S2=S1; S1=i*j;                                                     //вычисляем площадь следущую и предыдущую
       if(S2>=S1)                                                         //проверка максимального значения  
         {
          i--; j++;                                                       //возвращаем значения сторон соответствующие максимальной площади
          break;
         }
      }                 
//--------------------------------------------------------------------
Alert("Максимальная площадь равна ",S2,"mm*mm  A=",i,"mm B=",j,"mm");        
return(0);
  }
//--------------------------------------------------------------------

This algorithm works correctly, but if you swap the assignment operators in the header of the for statement in the first expression, the program no longer works. Why?

int start()                         
  {
//--------------------------------------------------------------------
   int
   S1,S2,                                                                 //S1 и S2 площадя следущего и предыдущего прямоугольников соответственно 
   j;                                                                     //значения стороны
//--------------------------------------------------------------------
   for(int i=1, j=499; i<500; i++,j--)                                    //последовательный перебор значений площади
      {
       S2=S1; S1=i*j;                                                     //вычисляем площадь следущую и предыдущую
       if(S2>=S1)                                                         //проверка максимального значения  
         {
          i--; j++;                                                       //возвращаем значения соответствующие максимальной площади
          break;
         }
      }                 
//--------------------------------------------------------------------
Alert("Максимальная площадь равна ",S2,"mm*mm  A=",i,"mm B=",j,"mm");        
return(0);
  }
//--------------------------------------------------------------------
 
VladimirR:

This algorithm works correctly, but if you swap the assignment operators in the header of the for statement in the first expression, the program no longer works. Why?






for(int i=1, j=499;

declare the j variable a second time

 
ilunga:

declare the j variable a second time

Thank you)))

 
VladimirR:

This algorithm works correctly, but if you swap the assignment operators in the header of the for statement in the first expression, the program no longer works. Why?







I wonder why the counter values should be changed twice in the loop. And for some reason there is no (preliminary) assignment of S2. At the start it is 0, and only on the second iteration (more precisely on the third) there is a real comparison of values (it depends on how to count from zero or from one)
 

This does not work either

int start()
{
int S1,S2; //S1 and S2 areas of the next and previous rectangles respectively
//----
for( int i=1, j=499; i<500; i++,j--) //several area values
{
S2=S1; S1=i*j; //calculate area next and previous
if(S2>=S1) //check maximum value
{
i--; j++; //return values corresponding to maximum area
break;
}
}
//----
Alert("Area equals ",S2, "mm*mm A=",i, "mm B=",j, "mm");
return(0);
}
//+------------------------------------------------------------------+
Reason: