price slippage on pending order

Dua Yong Rew
5248

Hi all,

is there any easy way to detect that the order executed price slipped from my pending order price?

William Roeder
27845
William Roeder  
  1. A pending order becomes a market order; there will be slippage.
  2. Remember the pending order price (perhaps a terminal variable) and compare to the opened price.
fxsaber
23312
fxsaber  
Dua Yong Rew:

is there any easy way to detect that the order executed price slipped from my pending order price?

#property script_show_inputs

#include <MT4Orders.mqh> // https://www.mql5.com/en/code/16006

input long inTicket = 0; // Position Ticket

#define PRINT(A) Print(#A + " = " + (string)(A))

void OnStart()
{
  if (OrderSelect(inTicket, SELECT_BY_TICKET))
  {
    OrderPrint();
    
    PRINT(OrderOpenPrice());       
    PRINT(OrderOpenPriceRequest());

    PRINT(OrderClosePrice());
    PRINT(OrderClosePriceRequest());
    
    PRINT(OrderTicketID());
  }
}


Result.

#3880043 2022.06.13 23:29:22.299 buy 0.03 USDCHF 0.99832 0.00000 0.99631 2022.06.14 04:02:44.569 0.99632 -0.12 -0.01 -6.02 4;[+5] 4

OrderOpenPrice() = 0.99832
OrderOpenPriceRequest() = 0.99837

OrderClosePrice() = 0.99632
OrderClosePriceRequest() = 0.99631

OrderTicketID() = 10965077


Or use the script CustomReport.

Dua Yong Rew
5248
Dua Yong Rew  
fxsaber #:


Result.


Or use the script CustomReport.

Thank you. This is very helpful