Don't know how to select the orders correctly in this way!

 

I saw "MQL4.com is moving to MQL5.com." However can't find the forum related MQL4.

Please let me ask the questions of MQL4 here. 

 

Let's say there are many loops of orders, each loop follows previous loop. In every loop, there are a series of orders and a whole loop means the series of orders are all closed based on a condition.

In order to recover the tracking once EA/terminal/PC is restarted while a loop is still ongoing, need select every order in this loop correctly. However, some orders are still open and some are closed already.

Once EA is restarted, only total orders in the ongoing loop can be retrieved, that is "ArrOrderSize" in the codes below. However, how to select the orders correctly now that some are still open and some are closed?

 

   for(int i=ArrOrderSize-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS)==true) 
      ......
      

  

 
moonsboy:

I saw "MQL4.com is moving to MQL5.com." However can't find the forum related MQL4.

Please let me ask the questions of MQL4 here. 

 

Let's say there are many loops of orders, each loop follows previous loop. In every loop, there are a series of orders and a whole loop means the series of orders are all closed based on a condition.

In order to recover the tracking once EA/terminal/PC is restarted while a loop is still ongoing, need select every order in this loop correctly. However, some orders are still open and some are closed already.

Once EA is restarted, only total orders in the ongoing loop can be retrieved, that is "ArrOrderSize" in the codes below. However, how to select the orders correctly now that some are still open and some are closed?

 

  

MQL4 questions are AOK here :)

Without seeing your full code and understanding what ArrOrderSize is, are you using  OrdersTotal()

 
Filter:

MQL4 questions are AOK here :)

Without seeing your full code and understanding what ArrOrderSize is, are you using  OrdersTotal()

Dear Filter, please try to understand what I want to ask and no need more codes here indeed.

"Once EA is restarted, only total orders,'ArrOrderSize', in the ongoing loop can be retrieved"

 
moonsboy:

I saw "MQL4.com is moving to MQL5.com." However can't find the forum related MQL4.

Please let me ask the questions of MQL4 here. 

 

Let's say there are many loops of orders, each loop follows previous loop. In every loop, there are a series of orders and a whole loop means the series of orders are all closed based on a condition.

In order to recover the tracking once EA/terminal/PC is restarted while a loop is still ongoing, need select every order in this loop correctly. However, some orders are still open and some are closed already.

Once EA is restarted, only total orders in the ongoing loop can be retrieved, that is "ArrOrderSize" in the codes below. However, how to select the orders correctly now that some are still open and some are closed?

 

  

I think you should use "for" with (int i=0;i=OrdersTotal()-1;i--)
 

Check MQL4 book examples on Closing and deleting orders and Order Accounting

This is tutorial style text with documented code examples. 

Closing and Deleting Orders - Programming of Trade Operations - MQL4 Tutorial
  • book.mql4.com
Closing and Deleting Orders - Programming of Trade Operations - MQL4 Tutorial