[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 72

 

Please suggest a course of action :))

if (...)

{

if(...)

{

if (...) false ->

}

else {...}

}

============================================

where does the execution go after FALSE -to else or even beyond the brackets of the first if ?

 
lottamer:

Please tell me how to proceed :))

if (...)

{

if(...)

{

if (...) false ->

}

else {...}

}

============================================

where does the execution go after FALSE -to else or even beyond the brackets of the first if ?

If I understand your curly braces correctly, then:

if (1<2) {
   if(2<3) {
      if (3>4) { 
         false ->
         }
      } 
   else  { иначе, если два больше три}
   }   
 
Hello, Could you please advise how to set the number of orders(with check on the symbol, the operation, and the magician), we need to make the expert open one order without paying attention to already open orders
 
dimarik0000:
Hello, Can you please advise how many orders (with check on the symbol, operation, and magik), I need to make an expert to open an order without paying attention to already open orders


This function returns the number of currently open positions

 
do you have such a function? if not difficult, please show an example of its use in the Expert Advisor code
 

I have written a function that should determine whether the position exists based on the entered tag and comment. If not, it should return the permission to open it.

When I use one trade signal in the Expert Advisor, everything works fine: it opens a position only when there is no other with the same conditions. But when the Expert Advisor works with several types of signals that I label with a different comment, it opens multiple positions. What is the problem?

bool TwoOrders(int magic, string comment)
 {
  int to;
  for(to=0; to<=OrdersTotal(); to++)
   {
    if(OrderSelect(to,SELECT_BY_POS)==true)
     {
      if(OrderMagicNumber()==magic)
       {
        if(OrderComment()==comment)
         {
          return(false);
         }
        else return(true);
       }
      else return(true); 
     }
    else return(true);
   }
 } 

   Type1=TwoOrders(ExpertID,"type1");
   Type2=TwoOrders(ExpertID,"type2");
     if(Type1==true)
      {
       Ans=OrderSend(Symb,OP_BUYSTOP,Lts,OpnPrice,30,SL,TP,"type1",ExpertID,0);
       if(Ans==false)
        {
         Alert("Ошибка при открытии BUY-STOP ордера: ", GetLastError());
        }
      }
     if(Type2==true)
      {
       Ans=OrderSend(Symb,OP_BUYLIMIT,Lts,OpnPrice,30,SL,TP,"type2",ExpertID,0);
       if(Ans==false)
        {
         Alert("Ошибка при открытии BUY-STOP ордера: ", GetLastError());
        }
      }
 
silhouette:

I have written a function that should determine whether the position exists based on the entered tag and comment. If not, it should return the permission to open it.

When I use one trade signal in the Expert Advisor, everything works fine: it opens a position only when there is no other with the same conditions. But when the Expert Advisor works with several types of signals that I label with a different comment, it opens multiple positions. What is the problem?

Are you sure that in the order comment the DC won't add something of his own? You need to look for a substring in the order comment. Or, better yet, don't go through this hassle. The position can be found using other, more reliable criteria.

 
artmedia70:

Are you at all sure that the DC will not add something of his own to the order comment? You need to look for a substring in the order comment. Better yet, don't go through this hassle. The position can be found using other, more reliable criteria.



By different mages, for example?

But in any case, the error is somewhere in the code, in theory. All the same, I wonder where.

 
dimarik0000:
do you have such a function? if you can show an example of its use in the expert's code


//вызываем
NumberOfPositions(NULL,OP_BUY,1234); //текущий график, OP_BUY, 1234 магик 

NumberOfPositions(NULL,OP_SELL,1234); //текущий график, OP_SELL, 1234 магик 

NumberOfPositions();//общее кол.

саму функцию, за пределами функции start()
 
r772ra:



I finally figured out how and where to put what! Thank you so much