closing time for last order

 

Hi all, I'm trying to recall the closing time for the last order executed on the account for a certain currency.

What do you think about this code?

Thank you!

total_history = OrdersHistoryTotal( ) ;
  
  for(cnt=0;cnt<=total_history;cnt++)
     {
     OrderSelect(cnt, SELECT_BY_POS, MODE_HISTORY);
     if (OrderSymbol()==Symbol() && OrderMagicNumber()==1) 
        {  
        Closing_Time = OrderCloseTime() ; 
        }  
     }  
 
Alberto_jazz:

Hi all, I'm trying to recall the closing time for the last order executed on the account for a certain currency.

What do you think about this code?

Thank you!


not good

OrderMagicNumber()==1 means that only magicnr 1 wil be selected so this won't work if you use for your trades other magficnumber

Closing_Time you don't check if the selected trade is closed later or earlier then the trades already checked

not an error in this case but check trades in a loop always counting down

 
Alberto_jazz:

Hi all, I'm trying to recall the closing time for the last order executed on the account for a certain currency.

What do you think about this code?

Thank you!

Your code will not pickup the lastorder, since it's not comparing the orders. I have answered this question in a different thread(with working sample code), look for my code sample in the thread link below, you can get the time and currency of the last trade, just look for my comments and change to how ever fits your needs....

https://www.mql5.com/en/forum/140455

Reason: