Forex Factory (https://www.forexfactory.com/)
-   Platform Tech (https://www.forexfactory.com/forum/69-platform-tech)
-   -   How does expiration on pending order works? (https://www.forexfactory.com/thread/312660-how-does-expiration-on-pending-order-works)

Georgebaker Sep 1, 2011 9:43am | Post# 1

How does expiration on pending order works?
 
I have found this line of code but it is not creating a buy limit order if i use this code

Here's a code snipit to set expiration time to 10 min:

PHP Code:
int et TimeCurrent()+(PERIOD_M5*60)*2;
 
OrderSend(Symbol(),OP_BUYSTOP,0.100,3,0,0,"0",0,et,Green); 
I need to set the expiration time to 3 min. How should the code look like if i want to that?

Tried this but doesn't work eather

PHP Code:
int expiration TimeCurrent()+(PERIOD_M1*60)*3
It's not placing the limit order

RaptorUK Sep 1, 2011 10:10am | Post# 2

Are you checking your returned error ? maybe your Broker doesn't allow you to set an expiration time or the time you are trying to set is too short ?

You must check the errors you get back when trying to place an order . . .

Georgebaker Sep 1, 2011 10:30am | Post# 3

ehh no i don't think so.

How can i show that code? Is it something like

return();

and then use the "comment" code to show it on the screen?

My ordersend looks like this : int ticket = OrderSend(Symbol(),OP_BUYLIMIT,1.0,Bid-100*point,0,0,0,"My Expert",16384,expiration,Blue);

RaptorUK Sep 1, 2011 11:09am | Post# 4

My ordersend looks like this : int ticket = OrderSend(Symbol(),OP_BUYLIMIT,1.0,Bid-100*point,0,0,0,"My Expert",16384,expiration,Blue);
OrderSend returns either the ticket number or -1 if the send failed . . so

if (OrderSend(Symbol(),OP_BUYLIMIT,1.0,Bid-100*point,0,0,0,"My Expert",16384,expiration,Blue) < 0) Comment("OrderSend failed: error ", GetLastError());

Georgebaker Sep 1, 2011 11:29am | Post# 5

Ok it says:

OrderSend failed error: 3

Georgebaker Sep 1, 2011 11:35am | Post# 6

I'm using FXDD, do you know what code 3 means or do i have to ask the broker?

RaptorUK Sep 1, 2011 11:38am | Post# 7

Ok it says:

OrderSend failed error: 3
ERR_INVALID_TRADE_PARAMETERS 3 Invalid trade parameters.

Try a longer period, maybe 24hrs

RaptorUK Sep 1, 2011 11:39am | Post# 8

I'm using FXDD, do you know what code 3 means or do i have to ask the broker?
If you look in the Toolbox of MetaEditor under help you can find all the MQL4 syntax and error messages there . .


MQL4 Reference - Standard constants - Error codes

Georgebaker Sep 1, 2011 11:46am | Post# 9

Ok thanks for the information!

Georgebaker Sep 1, 2011 12:02pm | Post# 10

ERR_INVALID_TRADE_PARAMETERS 3 Invalid trade parameters.

Try a longer period, maybe 24hrs
I did a few test and it work with 15min, but not with 5min so there we have the answer. The broker doesn't allow expiration time below 5 min.

Problem solved!

Thanks for your help RaptorUK.


© Forex Factory