Expiration Pending Orders

 

Hello,

 

does anyone know how does the experation function fo pending orders Works in MQL5?

 

i found there is an Void

https://www.mql5.com/en/docs/standardlibrary/expertclasses/expertbaseclasses/cexpertsignal/cexpertsignalexpiration 

 

but also you have the constant from the order Send Function

ENUM_ORDER_TYPE_TIME

Identifier

Description

ORDER_TIME_GTC

Good till cancel order

ORDER_TIME_DAY

Good till current trade day order

ORDER_TIME_SPECIFIED

Good till expired order

ORDER_TIME_SPECIFIED_DAY

The order will be effective till 23:59:59 of the specified day. If this time is outside a trading session, the order expires in the nearest trading time.


when i look back to MT4 this was easy, for 10 Minutes Experation I entered TimeCurrent() + 10*60 and thats all

how it works here?

 

amando 

Documentation on MQL5: Standard Library / Strategy Modules / Base classes for Expert Advisors / CExpertSignal / Expiration
Documentation on MQL5: Standard Library / Strategy Modules / Base classes for Expert Advisors / CExpertSignal / Expiration
  • www.mql5.com
Standard Library / Strategy Modules / Base classes for Expert Advisors / CExpertSignal / Expiration - Reference on algorithmic/automated trading language for MetaTrader 5
 

does anyone can explain?

 

amando 

 
amando:

does anyone can explain?

 

amando 

Explain what ? It's pretty clear and self-explanatory.

If you want to specify an expiry like with MT4, you have to use ORDER_TIME_SPECIFIED and set your expiry time.

 
Alain Verleyen:

Explain what ? It's pretty clear and self-explanatory.

If you want to specify an expiry like with MT4, you have to use ORDER_TIME_SPECIFIED and set your expiry time.

how you mean this Alain?

does this mean i have to use 

 

 newOrder.expiration = TimeCurrent() +10*60; for 10 minutes expiration 

instead of  

  newOrder.expiration   = ORDER_TIME_SPECIFIED;

?

 

amando 

 
amando #:

does anyone can explain?

 

amando 


In case you need a sample. This is a Buy Stop with expired time:

#include <Trade\Trade.mqh>
CTrade myTrade;

datetime expTime=TimeCurrent()+600;

if(myTrade.BuyStop(Lots,SymbolInfoDouble(_Symbol,SYMBOL_ASK)+(100*_Point),NULL,0,0,ORDER_TIME_SPECIFIED,expTime,"Buy Stop")) Print("Order created");

 
amando: does anyone know how does the experation function fo pending orders Works in MQL5?
  1. answered at #4.
  2. There is no need to create pending orders in code.

    1. The pending has the slight advantage, A) you are closer to the top of the queue (filled quicker), B) there's no round trip network delay (filled quicker.)

      Don't worry about it unless you're scalping M1 or trading news.

    2. Humans can't watch the screen 24/7, so they use pending orders; EAs can, so no need for pending orders, have it wait until the market reaches the trigger price and just open an order.

Reason: