648

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
485

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).
648

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
485

```datetime et = ((24 - Hour()) * 60 - Minute()) * 60 - Seconds();

if (et < 660)
et = 0; // or = 660. OrderSend() returns ERR_INVALID_PARAMETERS if et < 660.```
648

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
6

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" .

2441

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);

1349

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 ...........????

2326

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.

1590

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.

32

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);

}