Download MetaTrader 5

OP_BUYLIMIT Expiration Time

To add comments, please log in or register
Wackena
648
Wackena  
I need an example of how to set expiration time in a pending order.

In this example, the expiration time is 0. I need example of pending order "Good for the Day Only".

ticket=OrderSend(Symbol(),OP_BUYLIMIT,1,1.3104,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);
Thanks,

Wackena
Glaswegian
485
Glaswegian  
The expiration time is set in seconds and cannot be less than 11 minutes (that may depend on broker's server setup or hardcoded in the terminal, I don't know exactly).

Hence the day length time 24 * 60 * 60.
Or number of seconds until midnight if you need it to last for the current day only (not less than 660 though).
Wackena
648
Wackena  
Irtron:
The expiration time is set in seconds and cannot be less than 11 minutes (that may depend on broker's server setup or hardcoded in the terminal, I don't know exactly).

Hence the day length time 24 * 60 * 60.
Or number of seconds until midnight if you need it to last for the current day only (not less than 660 though).

Thank you. Do you have a code sequence that will calculate remaining time in same day when OrderSend() OP_BUYLIMIT is placed?

Wackena
Glaswegian
485
Glaswegian  
datetime et = ((24 - Hour()) * 60 - Minute()) * 60 - Seconds();
 
if (et < 660)
    et = 0; // or = 660. OrderSend() returns ERR_INVALID_PARAMETERS if et < 660.
Wackena
648
Wackena  
Irtron:

datetime et = ((24 - Hour()) * 60 - Minute()) * 60 - Seconds();
 
if (et < 660)
    et = 0; // or = 660. OrderSend() returns ERR_INVALID_PARAMETERS if et < 660.




Irtron,
Thanks,
Wackena
m0j1
6
m0j1  

hi, I have the same problem, I want to set pendings with expiration for the next hour . as you say, I should set the expiration 3600 . but when I write my ordersend like this:

int sellticket=OrderSend(Symbol(),OP_SELLSTOP,0.1,Bid-15*Point,5,Bid-5*Point,Bid-30*Point,NULL,0,3600,Red);

it gives me "OrderSend error 3" .

Alexander
2441
Alexander  
Replace

int sellticket=OrderSend(Symbol(),OP_SELLSTOP,0.1,Bid-15*Point,5,Bid-5*Point,Bid-30*Point,NULL,0,3600,Red);

to

int sellticket=OrderSend(Symbol(),OP_SELLSTOP,0.1,Bid-15*Point,5,Bid-5*Point,Bid-30*Point,NULL,0,TimeCurrent()+3600,Red);

Desmond Wright
1349
Desmond Wright  
Roger:
Replace

int sellticket=OrderSend(Symbol(),OP_SELLSTOP,0.1,Bid-15*Point,5,Bid-5*Point,Bid-30*Point,NULL,0,3600,Red);

to

int sellticket=OrderSend(Symbol(),OP_SELLSTOP,0.1,Bid-15*Point,5,Bid-5*Point,Bid-30*Point,NULL,0,TimeCurrent()+3600,Red);



TimeMinute(TimeCurrent()+10 ...........????

gordon
2326
gordon  
buju:

TimeMinute(TimeCurrent()+10 ...........????

No. TimeMinute() returns the minute of the input time (0,1,2...59). Expiration should be in standard unix time (in seconds passed since 1 Jan 1970). Roger's comment is correct.

JC
1590
JC  
gordon:

Expiration should be in standard unix time (in seconds passed since 1 Jan 1970). Roger's comment is correct.

...And some brokers have minimum expiry periods. For example, I seem to remember that IBFX appear to have a complex rule where expiry cannot be earlier than the start of the tenth minute from now - i.e. a minimum of anything from 541 to 600 seconds away.

Tusa Busi
32
Tusa Busi  
Roger:
Replace

int sellticket=OrderSend(Symbol(),OP_SELLSTOP,0.1,Bid-15*Point,5,Bid-5*Point,Bid-30*Point,NULL,0,3600,Red);

to

int sellticket=OrderSend(Symbol(),OP_SELLSTOP,0.1,Bid-15*Point,5,Bid-5*Point,Bid-30*Point,NULL,0,TimeCurrent()+3600,Red);

I have tries this in my code and it did not work. I get OrderSend() Error 147. Using fxcm mt4(the old one; they made a new one recently). Here is a piece of my code:

if(TCheck()==True && Total_H==0){

OrderSend(Symbol(),OP_SELLSTOP,V, LOW, 2, LOW+StopLoss*10*Point, LOW-TakeProfit*10*Point, NULL, 0, TimeCurrent()+84600, Yellow);

OrderSend(Symbol(),OP_BUYSTOP, V, HIGH, 2,HIGH-StopLoss*10*Point, HIGH+TakeProfit*10*Point, NULL, 0, TimeCurrent()+84600, Yellow);

}

12
To add comments, please log in or register