Invalid Expiration no matter what i do trying pending order. Error 10022 - Demo Trading - Expert Advisors and Automated Trading - MQL5 programming forum

Invalid Expiration no matter what i do trying pending order. Error 10022

 

I am trying to post a pending Orderasync on a DEMO account but no matter i do the error persist.

The symbol specification says Order Expiration : TODAY

Here goes my code and tries:

bool Trade_OrderAsync(double volume, ENUM_ORDER_TYPE MyOrderType, double Order_Price, double Order_Stop_Loss_Price, double Order_Take_Profit_Price, MqlTradeResult &res)
  {
   datetime expiration = TimeCurrent()+PeriodSeconds(PERIOD_M5);
   ZeroMemory(res);
//--- prepare the request
   MqlTradeRequest req={};
   req.action      = TRADE_ACTION_PENDING;
   req.symbol      = _Symbol;
   req.volume      = volume;
   req.type        = MyOrderType;// Tried ALL TYPES OF PENDING ---> ORDER_TYPE_BUY_STOP_LIMIT, ORDER_TYPE_BUY_STOP, ORDER_TYPE_BUY_LIMIT and sell equivalents
   req.price       = Order_Price;
   req.sl          = Order_Stop_Loss_Price;
   req.tp          = Order_Take_Profit_Price;
   req.deviation   = 20;
   
   req.magic       = 12345;
   req.expiration  = expiration;
   req.type_filling = ORDER_FILLING_FOK;
   req.type_time    = SYMBOL_EXPIRATION_DAY;// ORDER_TIME_GTC; //ORDER_TIME_SPECIFIED;
   
   if(!OrderSendAsync(req,res))
     {
      Print(__FUNCTION__,": error ",GetLastError(),", retcode = ",res.retcode);
      return false;
     }else{
      return true;
     }
//---
  }

I don´t need to set expiration. I am setting it cause i got error.

Using OrderOpen it works OK(without expiration set).

Any hint?

 
mqlmaster4 I am trying to post a pending Orderasync on a DEMO account but no matter i do the error persist. The symbol specification says Order Expiration : TODAY Here goes my code and tries: I don´t need to set expiration. I am setting it cause i got error. Using OrderOpen it works OK(without expiration set). Any hint?

See the following topic about B3: Retcode Error 10022 MT5 Robot

 

Thanks.

Now it is returning 10015 Invalid Price for ALL combinations of price/sl/tp.

I am guessing this procedure does not accept orders of type ORDER_TYPE_BUY_STOP_LIMIT or ORDER_TYPE_SELL_STOP_LIMIT.

For other pending order types it´s working.

 
mqlmaster4 # Thanks. Now it is returning 10015 Invalid Price for ALL combinations of price/sl/tp. I am guessing this procedure does not accept orders of type ORDER_TYPE_BUY_STOP_LIMIT or ORDER_TYPE_SELL_STOP_LIMIT. For other pending order types it´s working.

See guidance on ORDER_TYPE_BUY_STOP_LIMIT and ORDER_TYPE_SELL_STOP_LIMIT: Error 10022 with pending order WINV16

 

Thank you very much!

It´s now working with both ORDER_TYPE_BUY_STOP_LIMIT and ORDER_TYPE_SELL_STOP_LIMIT.

Salvou!. Valeu!

 
mqlmaster4 #Thank you very much! It´s now working with both ORDER_TYPE_BUY_STOP_LIMIT and ORDER_TYPE_SELL_STOP_LIMIT. Salvou!. Valeu!

You are welcome!! 👍😊

Reason: