Set an OrderSend with an expiration of 5 minutes

 

Hello,

I try since Friday to creat an EA that can open orders of 5 mintues expiration cause I will link it later to a Binary options plateform. I almost used all solution on this forum
creat a datetime variable in order to use for closing the order:

Exemple 1: 

datetime et = Time[0]+(5*60);

int ticket = OrderSend(Symbol(), OP_BUY, 0.2, Ask, 3, 0, 0, "",0, et, clrGreen);

Exemple 2:

datetime et = TimeCurrent()+(5*60);

int ticket = OrderSend(Symbol(), OP_BUY, 0.2, Ask, 3, 0, 0, "",0, et, clrGreen); 

 

Second Option directly put the  expiration on the fonction:

 int ticket = OrderSend(Symbol(), OP_BUY, 0.2, Ask, 3, 0, 0, "",0, TimeCurrent()+300, clrGreen); 

 

NOOOOOOOthing work when I check with a backtest !!!!
I want that EA to open an order & to close it after 5 minutes, that's the only condition I wanna use !!!

 

Can you Help me please!!!

thnks 

 
zerocold:

I try since Friday to creat an EA that can open orders of 5 mintues expiration cause I will link it later to a Binary options plateform. I almost used all solution on this forum 

creat a datetime variable in order to use for closing the order:

Most brokers (?all copies of MT4) have minimum expiry times longer than 5 minutes. The information in the old thread https://www.mql5.com/en/forum/101886 still seems to be correct.

 
Expiry times are for pending orders only. It should cancel a pending order if it has not been triggered. It will not close an open OP_BUY or OP_SELL
 
  1. Use SRC to post code
  2. Expiration can only be used with pending orders. What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  3. Some brokers do not allow expiration at all

    147

    ERR_TRADE_EXPIRATION_DENIED

    Expirations are denied by broker

Reason: