Questions from Beginners MQL4 MT4 MetaTrader 4 - page 142

 
Ihor Herasko:

The second form, on the other hand, is unclear. After all, it is responsible for the time in the future or the past.

Yes, they have not documented this point. Then it is better not to rely on the second form of the function to check the availability of the trade flow.

One more question. Let's say, when the EA attempts to open an order with a busy trade thread, will we always get the same error number, namely '146'? Or, maybe there will be some other error?

 
Asa saas:

Yes, somehow this point is not documented. Then it is better not to rely on the second form of the function to check if the trade flow is available.

There is also one more question. Let us say, when the EA makes an attempt to open an order when a thread is busy, will we always get the same error number, namely, '146'? Or, will there be some other error?

It may not get to the point of sending the order because of other errors. Why find out about the thread availability at all in this way? It would be much easier to use the function checking if the thread is busy.

 
Ihor Herasko:

It may not get to the point of sending the order because there are other errors. Why find out about thread occupancy in this way at all? It is easier to use the thread occupancy check function.

Thank you, I will do so.

 
Hi all!!! How do I open orders one by one!!! i.e. open sell, then buy and so on in turn???
 
sviter-pro:
Hi all!!! How do I open orders one at a time!!! i.e. open sell, then buy and so on???

you can

How many orders do I have to open?

 
one sell, then one Buy, then sell, then one Buy and so on!
 
sviter-pro:
one sell, then one Buy, then sell, then one Buy and so on!
You will run into a margin crunch.
 
well i'm experimenting!!! logic is specific!!! help?
 
How to make a function which would close an open position by its own bridge after a specified number of candles have passed in the time history.
 
Лауреат:
How to make a function which would close an open position by its own bridge after a specified number of candles have passed in the time history.
for(int i = 0; i < 36; i++) // 36 - история 36 свечей
  {
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
     {
      if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic)
        {
         if(OrderType()==OP_BUY)
           {
            bool  OrderClose(

   int        ticket,      // номер ордера
   double     lots,        // количество лотов
   double     price,       // цена закрытия
   int        slippage,    // максимальное проскальзывание
   color      arrow_color  // цвет
   );
           }

         if(OrderType()==OP_SELL )
           {
           bool  OrderClose(

   int        ticket,      // номер ордера
   double     lots,        // количество лотов
   double     price,       // цена закрытия
   int        slippage,    // максимальное проскальзывание
   color      arrow_color  // цвет
   );
           }
        }
     }
  }
return;
}
Reason: