invalid expiration

 

Hello all,

I am building an EA and it is properly sending orders, but every time it reports [invalid expiration].

I would need this EA to send orders as pending orders, since the strategy requires a start order.

 

The code I have is below, please advise.

 

    MqlTradeRequest request;

   MqlTradeResult result;

   ZeroMemory(request);

   ZeroMemory(result);

   datetime expiration = TimeCurrent()+PeriodSeconds(PERIOD_M30); 


   request.symbol       = Symbol();

   request.volume       = Lots;

   request.stoplimit    = 0;

   request.sl           = 0;

   request.tp           = 0;

   request.type_filling = ORDER_FILLING_FOK;

   request.type_time    = ORDER_TIME_SPECIFIED;

   request.expiration = expiration;

   request.type=ORDER_TYPE_BUY_STOP;

   request.price=myprice;

   request.tp=mytp;

   dummy = OrderSend(request, result);


 
You did not specify an action for the request. Should be  TRADE_ACTION_PENDING.
 
marketeer:
You did not specify an action for the request. Should be  TRADE_ACTION_PENDING.

My mistake: the action is there indeed.

Here goes the full code again below.

 

    MqlTradeRequest request;

   MqlTradeResult result;

   ZeroMemory(request);

   ZeroMemory(result);

   datetime expiration = TimeCurrent()+PeriodSeconds(PERIOD_M30); 

   request.symbol       = Symbol();

   request.volume       = Lots;

   request.stoplimit    = 0;

   request.sl           = 0;

   request.tp           = 0;

   request.type_filling = ORDER_FILLING_FOK;

   request.type_time    = ORDER_TIME_SPECIFIED;

   request.expiration = expiration;

   request.action=TRADE_ACTION_PENDING; 

   request.type=ORDER_TYPE_BUY_STOP;

   request.price=myprice;

   request.tp=mytp;

   dummy = OrderSend(request, result); 
 

Forum on trading, automated trading systems and testing trading strategies


Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.


 
aecioneto:

My mistake: the action is there indeed.

Here goes the full code again below.

 

Did you check that ORDER_TIME_SPECIFIED is allowed for the symbol you trade ?
 
angevoyageur:
Did you check that ORDER_TIME_SPECIFIED is allowed for the symbol you trade ?

Many thanks, I did not know this!

I should use the code to verify this in the expert code, right? 

 
aecioneto:

Many thanks, I did not know this!

I should use the code to verify this in the expert code, right? 

Yes, it's broker/symbol dependent. It's probably your problem, please report here when you will check.
 
angevoyageur:
Yes, it's broker/symbol dependent. It's probably your problem, please report here when you will check.

Just to complete my understanding on this: I can use the mouse to manually create a pending order, buy/sell stop.

Doing the same via EA is a different thing? 

 
aecioneto:

Just to complete my understanding on this: I can use the mouse to manually create a pending order, buy/sell stop.

Doing the same via EA is a different thing? 

I don't think so. What I wrote is only a suggestion, please try it and report the result.
 
angevoyageur:
I don't think so. What I wrote is only a suggestion, please try it and report the result.

Just did tests and results were key!!

Only SYMBOL_EXPIRATION_DAY is allowed. I changed code to only use it with BUY_LIMIT and SELL_LIMIT orders and now orders are routing throught.

Infinite thanks, man! 

Reason: