Download MetaTrader 5
To add comments, please log in or register
Move from theory to practice. Code Base will help you!
Taric
25
Taric 2015.12.08 21:51 
// Current order 

// [#1] [#2] [#4] 

 

for (int pos = 0; pos < OrdersTotal(); ++pos)


// when pos is 0, [#1] is selected.

if (OrderSelect(pos, SELECT_BY_POS) == false)

{

}



// (1) long long process... (More than 10 sec) 

// canceled or closed order [#1] [#2] and new order [#5]  => [#4] [#5]

// then next loop (pos is 1)

// OrdersTotal() return 2 and OrderSelect() select [#5] => Warning: [#4] is skipped !

 

How to avoid the above problem ? 
Keith Watford
Moderator
7887
Keith Watford 2015.12.08 22:11  
   while(true)
     {
      //Do something
      if(everything completed and want to leave loop)
        break;
     }
You have to have a break to exit the loop as while(true) will always be true.
Taric
25
Taric 2015.12.08 22:47  
GumRai:
You have to have a break to exit the loop as while(true) will always be true.

Commonly Your answer is ok but It isn't that I want to know....

 I just want to know that the problem occurs instantaneously as above.

and solution. 

 

Another example

for (int pos = 0; pos < OrdersTotal(); ++pos)

{

if (OrderSelect(pos, SELECT_BY_POS) == false)

{

// EA process this line, if instantaneously order count is changed.

}

Keith Watford
Moderator
7887
Keith Watford 2015.12.08 23:18  

As you have not described what problems you are having and your examples don't make any sense, it is not possible to give you any advice.

As your first example was an endless loop, I gave the only answer that was possible. 

Taric
25
Taric 2015.12.09 12:31  
GumRai:

As you have not described what problems you are having and your examples don't make any sense, it is not possible to give you any advice.

As your first example was an endless loop, I gave the only answer that was possible. 

 

Sorry, I changed example of problem.

/
To add comments, please log in or register