Order fill time in MQL5

 

I'm getting a bit frustrated on how to get order fill time in MQL5. Used the following just to get the information from the last order.

HistorySelect(0,TimeCurrent()); 
ulong first_order,last_order,orders=HistoryOrdersTotal(); 
last_order=HistoryOrderGetTicket(0); 
datetime ordertimedone = HistoryOrderGetInteger(last_order,ORDER_TIME_DONE);

My confusion/frustrations are:

1) MQL5 doesn't register any order in HistoryOrdersTotal until it is filled.

2) The time returned seemed to be wrong:

  • In this example the order was placed at 03:10.
  • PositionsTotal() and HistoryOrdersTotal() only returned 1 at 03:14 which indicates it took a few minutes to fill
  • At 03:14, ordertimedone above returned 03:10 which is the time the order was placed, not filled
  • Before 03:14, ordertime returned 01.01.1970 00:00:00

What is the easiest way to get the time orders are placed and filled? I want to do this check inside OnTick

I note that in MQL5 OrdersTotal(0) returns number of pending orders, where  OrdersTotal() in MQL4 returned number of both market and pending orders.

 
Anyone please?
 
dakr2019:
Anyone please?

What is the problem actually ? There is not, just your understanding about how it works is incomplete.

Maybe this article will help.

Orders, Positions and Deals in MetaTrader 5
Orders, Positions and Deals in MetaTrader 5
  • www.mql5.com
The ultimate goal of a trader is to extract profits through the means of trading operations on the financial markets. This article describes the terms and processes of the MetaTrader 5 trading platform, the knowledge of which is necessary for a proper understanding of the work of trade functions of the MQL5 language. Orders — are the trade...
 

Thanks very much this makes sense now that I need to get the time executed from the deal. I have a another question below please:

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

Modifying filled order
Modifying filled order
  • 2019.05.12
  • www.mql5.com
Hi, I can't seem to be able to modify an order. Example below...