[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 56

 
first_may:


Yes, I agree, I mispronounced it. After reading help, I decided to write it like this:

// the Expert Advisor can place orders every day of the session
// during the period from 10-45 to 18-30
if (Hour()>=10 && Minute()>=45 && Hour()<=18 && Minute()<=30)
{
...
}

Is this the correct condition to check the time?


No. You won't trade with this condition at all, since Minute()>=45 && Minute()<=30 is impossible in principle.

 
sergeev:

No. You won't trade at all with this condition because Minute()>=45 && Minute()<=30 is impossible in principle


So, you cannot compare hours and minutes separately? So, 11-55, for example, corresponds to the first condition, as 11>=10 & 55>=45, but not to the second one, as 11<=18 & 55<=30. Although in real life, 11-55 is just in the vinterval of hours from 10-45 to 18-30.
 
first_may:

It turns out that we cannot compare hours and minutes separately? For example 11-55 suits the first condition, as 11>=10 and 55>=45, but not the second, as 11<=18 and 55<=30. Although in real life, 11-55 is just in the vinterval of hours from 10-45 to 18-30.

you must create your start and end time with e.g. StrToTime
 
sergeev:

you have to create your own start and end times, e.g. StrToTime


Here, using the last known server time, wrote:
if (TimeCurrent()>=StrToTime("10:45") && TimeCurrent()<=StrToTime("18:30"))
{
...
}

Now 11-55 will fall into the 10-45 to 18:30 interval?

 
first_may:

Will 11-55 now fall between 10-45 and 18-30?

Yes.
 
sergeev:
Yes.


Thank you very much! :)
 

People, with all these global and local variables, I'm about to start running around barefoot and blowing sparrows. Man, I don't understand why there's so much headache in the middle of nowhere!

int Orders=0;                          // Объявление глобальной еременной суммы ордеров
int start()                            // Спец. функция start
  {
     if (MA2_2<MA1_2 && MA2_1>MA1_1)  //Сигнал на пересечении МА
        {
          if (OrdersTotal()>= 1) 
              return(0);               //Если ордеров больше 1, уходим.
   
          SL = 30;                     // Стоп лосс
          TP = 12;                     // Тейк профит
          S_Price = Low[1] - 1* Point; // Уровень установки SELLSTOP
          if (OrderSend (Symbol(), OP_SELLSTOP, Lots, S_Price, 0, SL, TP, "My order", Magic)>0) // Установка
//ордера SELLSTOP. Если OrderSend возвращает больше 0, то выполняем следующее.
            {
               Orders++;               //Увеличить величину Orders на 1. 
               Alert ("Ордер выставлен.Orders = ",Orders ); //Вывод нового значения Orders.
            }
        }    
   return(0);                             // Выход из start()
  }
As far as I know from MQL4 tutorial, now the new value of global variable Orders should equal 1. The next iteration should be 2, then 3. Then 4. And so on, until the Expert Advisor places pending orders. But I do not understand why the EA does not place pending orders! After placing another pending SELLSTOP order, every time I see only one message: Orders = 1! What is the reason? Can it be because of MetaEditor?
 
vovan-gogan:

People, with all these global and local variables, I'm about to start running around barefoot and blowing sparrows. Man, I don't understand why there's so much headache in the middle of nowhere!!!!

As far as I know from MQL4 tutorial, now the new value of global variable Orders should equal 1. The next iteration should be 2, then 3. Then 4. And so on, until the Expert Advisor places pending orders. But I do not understand why the EA does not place pending orders! After placing another pending SELLSTOP order, every time I see only one message: Orders = 1! What is the reason? Can it be because of MetaEditor?

The reason is that you have more market orders opened on this trading account.
 
Roman.:

The reason is that you have more market orders open on this trading account.

The saddest thing is that this happens in the tester. and pending orders are placed by the EA, but the Orders always equal 1
 
vovan-gogan:

The saddest thing is that this happens in the tester. The Expert Advisor places pending orders and Orders always equals 1

I guess you didn't phrase your question correctly.