Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 117

 

tell me how to treat such fences in meta-quotes quotes)?

 
Zhunko:
We need to intercept messages.

If the message has already been executed, it has already been deleted from the queue.

Ok, I have the following question.

#property indicator_chart_window
bool First = true;
int start(){
   if(First){
      int indexFirstLeftOnChart = WindowFirstVisibleBar();//иницилизируем под флагом, потому что в init() могут быть артефакты
      Alert("indexFirstLeftOnChart ", indexFirstLeftOnChart);
      First = false;
   }
   if(WindowFirstVisibleBar() != indexFirstLeftOnChart){//проверяем на каждом тике, изменилось ли значение
      Alert("first indexFirstLeftOnChart ", indexFirstLeftOnChart);      
      indexFirstLeftOnChart = WindowFirstVisibleBar();//если изменилось, записываем его
      Alert("second indexFirstLeftOnChart ", indexFirstLeftOnChart);
   }
   return(0);
}

- It beeps on every tick, because it turns out that first indexFirstLeftOnChart is zero. How do I fight this? Build 509.

 
static bool First = true;
 
gyfto:

If a message has already been executed, it has already been deleted from the queue.

Intercepts are usually made before execution. Otherwise, it's not clear why intercept?
 
static int indexFirstLeftOnChart;
 

I have something on a simple point, a headache. There is a function to search for orders.

t - counter of all orders.

p - counter of pending orders.

//+-------------------------------------------------------------------------------------+
//| Поиск своих ордеров                                                                 |
//+-------------------------------------------------------------------------------------+
void FindOrders(int& t, int& p)
{
   int total = OrdersTotal() - 1;
   t = 0;
   p = 0;
   for (int i=total; i>=0; i--)
   {
      if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
      if (OrderSymbol() != Symbol()) continue;
      if (OrderMagicNumber() != i_magic) continue;
      if (OrderType() > 1)
      {
          p++;
      }
      t++;
      pr ("FindOrders(): " + "t = " + t + "   " + TimeToStr(TimeCurrent()));
      pr ("FindOrders(): " + "p = " + p + "   " + TimeToStr(TimeCurrent()));
   }
}

I call it from the start:

int start()
{
   if (g_lastBarTime == Time[0])         // На текущем баре все необходимые действия..
       return (0);                               // ..уже были выполнены
   
   int oTotal = 0, oPending = 0;
   
   FindOrders(oTotal, oPending);
   
   int signal = GetGeneralSignal(oTotal);
   
   if (signal != SIGNAL_NO)
   {
       if (!Trade(signal))
       return(0);
   }
   else

In fact, when we open it, even when there are no orders, we see this (even when there are no orders, it prints as if there are...):

How is this possible?

 
Good evening everyone. I have decided to master MQL4 recently (I've been studying the tutorial by Sergey Kovalev). I decided to make a simple order opening script today for practice. The code is:
int start()
{
OrderSend("EURUSD",OP_BUY,0.1,Ask,3,Bid-15*Point,Bid+15*Point);
Alert(GetLastError());

return;

}

The script didn't work and error 4109 (Trading not allowed) was shown. When trying to change the situation, error 4016 (Uninitialised array) also appeared. I would like to know what causes these errors and how to create a simple trade opening script after all. I just copied the example from tutorial https://book.mql4.com/ru/trading/ordersend (I just added function GetLastError into it) and got error 4109 anyway.

int start()                                  // Спец. функция start()
  {                                          // Открытие BUY
   OrderSend(Symbol(),OP_BUY,0.1,Ask,3,Bid-15*Point,Bid+15*Point);
Alert(GetLastError());
   return;                                   // Выход из start()
  }

Кто может объяснить в чем проблема, буду очень признателен. Заранее спасибо.
 
deposit = type 6
 
Can you tell me if there is any way to set the comments on the order as default???
 
drems:
Can you tell me if there is any way to set default comments on the order???

What kind of "order"? What is it for? Where and why does it need a comment?