How to find last closed order?

 

Hi, I am new MQ4 developer. I have some question in my code. I need to find last close order from EA.

It can look by "OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY);" or not?

I don't sure, If select by position on history order. This list will order by close time or not?

thank...

 
smallrat wrote >>

Hi, I am new MQ4 developer. I have some question in my code. I need to find last close order from EA.

It can look by "OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY);" or not?

I don't sure, If select by position on history order. This list will order by close time or not?

thank...

Next time, do some homework.

OrderCloseTime() is the function you need.

It will give the last order close time.

 
smallrat:

It can look by "OrderSelect(OrdersHistoryTotal()-1,SELECT_BY_POS,MODE_HISTORY);" or not?

I don't sure, If select by position on history order. This list will order by close time or not?

No, it is not guaranteed that the list will be in order of close time. You need to loop through all the orders, looking for the latest OrderCloseTime().

 
I think it's follow the close and delete sequence.
Use OrderSymbol(), OrderMagicNumber(), OrderType() and OrderCloseTime() to shieve.
Reason: