[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 613

 
How do I check the absence of an open order or a pending order with a given magic number? We can check the presence of an order select, but how do I check the absence of an order?
 
sllawa3:
How can I check the absence of an open order or a pending order with a given magic number? We can check for an order select, but how can I check for an absence?

If there is no presence, then there is no presence :)))
 
Techno:
If there is no availability, then there is no availability :)))
yes... if... then the selector retains the value of availability of the last pose...
 
sllawa3:
Yes... if only... the selector retains the value of having the last pose...
The selector function doesn't save anything, it only picks the order from the incoming number, and this number is built in the loop
 
DDFedor:

- get the numbers of the outermost bars for the period in question.

- we use the maxima and minima search functions.

https://docs.mql4.com/ru/series/iLowest

https://docs.mql4.com/ru/series/iHighest

So it's pretty basic, isn't it?
   int      NBars,MostHiBar, MostLoBar;
   double   MostHiPrice,MostLoPrice;
   
//-----------------------------------------------------------------
   NBars       = 80;
   MostHiBar   = iHighest(NULL,PERIOD_D1,MODE_HIGH,NBars,0);      // Номер "максимального" бара
   MostLoBar   = iLowest (NULL,PERIOD_D1,MODE_LOW, NBars,0);      // Номер "минимального" бара
   MostHiPrice = iHigh   (NULL,PERIOD_D1,MostHiBar);              // Цена  "максимального" бара
   MostLoPrice = iLow    (NULL,PERIOD_D1,MostLoBar);              // Цена  "минимального" бара

   Comment (
            "\n", 
            "Наибольшая цена за ", NBars, " дней = ", MostHiPrice, "\n",
            "Наименьшая цена за ", NBars, " дней = ", MostLoPrice
           );
Right?
 
sllawa3:
How can I check the absence of an open order or a pending order with a given magic number? We can check for an order select, but how can I check for an absence?

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 06.03.2008                                                     |
//|  Описание : Возвращает флаг существования позиций                          |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - операция                   (-1   - любая позиция)                  |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//|    ot - время открытия             ( 0   - любое время открытия)           |
//+----------------------------------------------------------------------------+
bool ExistPositions(string sy="", int op=-1, int mn=-1, datetime ot=0) {
  int i, k=OrdersTotal();
 
  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==sy || sy=="") {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (ot<=OrderOpenTime()) return(True);
            }
          }
        }
      }
    }
  }
  return(False);
}
//жжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжжж
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 12.03.2008                                                     |
//|  Описание : Возвращает флаг существования ордеров.                         |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - операция                   (-1   - любой ордер)                    |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//|    ot - время открытия             ( 0   - любое время установки)          |
//+----------------------------------------------------------------------------+
bool ExistOrders(string sy="", int op=-1, int mn=-1, datetime ot=0) {
  int i, k=OrdersTotal(), ty;
 
  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      ty=OrderType();
      if (ty>1 && ty<6) {
        if ((OrderSymbol()==sy || sy=="") && (op<0 || ty==op)) {
          if (mn<0 || OrderMagicNumber()==mn) {
            if (ot<=OrderOpenTime()) return(True);
          }
        }
      }
    }
  }
  return(False);
}
if (ExistPositions(СИМВОЛ, ОПЕРАЦИЯ, МАГИК, ВРЕМЯ ОТКРЫТИЯ)==false) {код, если нету позиции}

It is the same for orders ...

 
 int ticket;
 int start()  
 {
 int prim=8;
 while(ticket<prim)
 {
 ticket++;
 }
 Print(ticket);
 return;
 }

When testing this code, the log gives a result of "8" an infinite number of times.
Can you tell me how to make the result is given only once.
Thank you.
 
Oper:

When testing this code, the log gives a result of "8" an infinite number of times.
Can you tell me how to make the result is given only once.
Thank you.
you can move this to the init() function.
 
sllawa3:

I have a problem ... help ...

The selector finds an order if there is an open but if there is no open how can I find it ? the selector will still show the last existing closed position ...


int DS=0;
for(int i = 0; i < OrdersTotal(); i++)
  {
    if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) // если под такой позицией ордер не выбран идём на следующий круг 
      { if(OrderSymbol() == Symbol())// если символ ордера не совпадает с символом инструмента идём на следующий круг
         { if(OrderMagicNumber() == MAGA) // если Magic ордера не совпадает с MAGA идём на следующий круг  
             {if(OrderType() == OP_BUY)DS++; // если дошли аж суда и тип бай то увеличиваем счётчик на 1
             }
         }
      }
  }
// если тут DS=0 значит открытых ордеров по текущему символу с заданным магиком типа бай нету

What is the problem ?

 
rebiata podskajute skolko stoil Maiatnik (Swinger) v 2008 gody?
Reason: