Which prevents the advisor from making money. - page 6

 
valenok2003: Roma, don't lie, the first time you wrote
while(OrderSelect(ticket,SELECT_BY_TICKET)==false)

Wrong. The whole cycle is like that:

while(OrderSelect(ticket,SELECT_BY_TICKET)==false)       // Если ордер выбран
                Sleep(100);        

True, the comment is wrong. But the cycle is exactly like this: until an order is selected - wait 100 milliseconds.

True, if there is no order with ticket already (closed), Roma will enter an infinite loop. Most likely, this check is done earlier.

 
Roman.:

This construct was originally in someone's post with the question: How do I know the price of an order? the answer I used in this loop - see above.

Here's that answer to that question:

there you have it, Roman. Sometimes the ticket comes back and the order is gone. And you will hang like a sweetie.

Besides, it's got to be there.

// If the order is NOT selected

PS You and I discussed this topic recently.

 

Oh, come on.....

What do you mean what will happen? I don't understand this question at all....

Read the doc - standard constants/errors - it says it all...

If you can't find it - error 4108

 
valenok2003:



Roma, don't lie, the first time you wrote

this design

while(OrderSelect(ticket,SELECT_BY_TICKET)==false)

is a part of the cycle to work online, I use it to get the characteristics of the selected order

// ------------------------------------------------Ищем наш ордер---------------------------------
   int orderType;
   for (int orderIndex = (OrdersTotal() - 1); orderIndex >= 0; orderIndex--)
   {
      if (!OrderSelect(orderIndex, SELECT_BY_POS))     continue;
      if ((OrderSymbol() != Symbol()) || (OrderMagicNumber() != MagicNumber)) continue;
      orderType = OrderType();
      if ((orderType != OP_BUY) && (orderType != OP_SELL)) continue;
          ticket = OrderTicket( );                         // Номер ордера
          orderLots = OrderLots();                         // Lots   
          orderProfit = OrderProfit() + OrderSwap();       // Profit
          Price = OrderOpenPrice();                        // Цена открытия рыночного ордера
          SL =  OrderStopLoss();                           // Значение StopLoss ордера
          TP = OrderTakeProfit();                          // Значение TakeProfit ордера          
          if (ticket>0)                                    // Если позиция открылась
              {
                while(OrderSelect(ticket,SELECT_BY_TICKET)==false)       // Если ордер выбран
                Sleep(100);                                 
                double OpenPrice=OrderOpenPrice();
       // Print("OrderTicket()=",OrderTicket(),  "OrderOpenTime()=",OrderOpenTime()); 
       // Print("TimeLocal()=",TimeLocal());                                                                    
                     //---------------------Запоминаем значения сл и тп ордера                     
                if (orderType == OP_BUY) 
                   {                
                     
                   }
            
                if (orderType == OP_SELL) 
                   {        
                     
                   }   
                            
               }
             
     // Проверка на предельную просадку      
      double loss = - ((orderProfit * 100.0) / AccountBalance());
      if (loss > MaxLoss)
      {
         Print ("MaxLoss");
         CloseAllOrders(MagicNumber);
         IsExpertFailed = true;
         return (0);
      }  
        
      return (0);
   }
   
 
 

I have already written how many times, after selecting an order, check the closing time, if !=0 then the order is already closed.

"And these people teach me to pick my nose..."

 

And when it gets stuck in your cycle... mother of God.

Вот эта строка вашше не очем : if (!OrderSelect(orderIndex, SELECT_BY_POS)) continue;

 
FAQ: "And these people teach me how to pick my nose..."

It comes to mind:

The son accidentally witnesses his parents having sex and thinks: "And these people still forbid me to pick my nose...".

 
Mathemat:

Wrong. The whole cycle is like that:

True, the comment is wrong. But the cycle is exactly like this: until an order is selected, wait 100 milliseconds.
Yes I forgot to add a line in this post, but there is one in other posts, where the full answer to this question is...
 

Man, when are you going to learn not to write compound ifs, you're too lazy to add a line, and when you start analyzing it, you'll smash your head against the wall.

And besides, it takes longer than two separate

 
FAQ:

I have already written how many times, after selecting an order, check the closing time, if !=0 then the order is already closed.

"And these people teach me to pick my nose..."

Yeah, by the way, I'm remembering now...

If you've got any around here, can you copy that... with a time control, something like - if it's not equal to/equal to zero... because only closed orders have a closing time...

Reason: