When the order is market execution, how to calculate the slippage from the order history?

 

I know how to calculate slippage according Stoploss, Takeprofit, and PendingOrder.

But If we trade with market execution,  the order table price look in the pic:

we can record price in EA, but it is inconvenient. 

So, Does anyone know of a good way to detect slippage in market orders?

 
Yu Zhang:

I know how to calculate slippage according Stoploss, Takeprofit, and PendingOrder.

But If we trade with market execution,  the order table price look in the pic:

we can record price in EA, but it is inconvenient. 

So, Does anyone know of a good way to detect slippage in market orders?

It is the same way for every order type.

You get it straight out of the history with MT5 (does not work on MT4). 

Difference between the price of out/in/inout deal and the order price as per example 163.126 - 163.122 == +4.

A transparent broker also writes the slippage to the comment section or provides the option to do so. In this case you have the option to extract it from the comment field.

 
Enrique Dangeroux #:

It is the same way for every order type.

You get it straight out of the history with MT5 (does not work on MT4). 

Difference between the price of out/in/inout deal and the order price as per example 163.126 - 163.122 == +4.

A transparent broker also writes the slippage to the comment section or provides the option to do so. In this case you have the option to extract it from the comment field.

according to your picture, price is 163.126 and 163.122.

But my Orders & Deals is :

The First is market, there is not record any price. Because I trade with market execution.

 
Yu Zhang #:

according to your picture, price is 163.126 and 163.122.

But my Orders & Deals is :

The First is market, there is not record any price. Because I trade with market execution.

The price is there, the terminal is not transparent about it. Check it with code. The in/out deal is the requested price, get the order open price or order close price and calculate the difference.

I do not have access to  my code at the moment. Run this https://www.mql5.com/en/code/19019 script and you will now where to get the price from.
 

Trade with market execution, HistoryOrderGetDouble(deal_order,ORDER_PRICE_OPEN) is 0. 

The Script I try it, it is also 0 if trade with market.



Enrique Dangeroux #:

The price is there, the terminal is not transparent about it. Check it with code. The in/out deal is the requested price, get the order open price or order close price and calculate the difference.

I know we can get in/out deal price. But I want to calculation slippage. So we must get "ordersend price" and "real deal price". But if we trade in market, the "ordersend price" is 0.

 
Does anyone studied this problem?

 
Yu Zhang #:
Does anyone studied this problem?

Get to order setup time in milliseconds, check ticks history to get to price at that time.

As the minimum time resolution is millisecond and you can have several ticks in that millisecond, it may happen you will not be able to know the exact slippage.

Reason: