Expiration Not Working?

 

I get this response when sending a pending order with ORDER_TIME_SPECIFIED expiration:

2013.03.18 00:26:10 - Error Sending Buy Stop: 4756 (invalid expiration)
2013.03.18 00:26:10 - Volume = 0.04 Entry = 1.30655 SL = 1.29068 TP = 1.32036 Bid/Ask = 1.29176/1.29182 Exp: 2013.03.18 00:30:00

Even though I check SYMBOL_EXPIRATION_MODE:

   int exp_mode = (int)SymbolInfoInteger(_Symbol, SYMBOL_EXPIRATION_MODE);
   if ((exp_mode & 4) != 4) ExpirationEnabled = false;

Am I missing anything else?

PS: If I switch to ORDER_TIME_GTC, order goes through without errors.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
 
enivid:

I get this response when sending a pending order with ORDER_TIME_SPECIFIED expiration:

2013.03.18 00:26:10 - Error Sending Buy Stop: 4756 (invalid expiration)
2013.03.18 00:26:10 - Volume = 0.04 Entry = 1.30655 SL = 1.29068 TP = 1.32036 Bid/Ask = 1.29176/1.29182 Exp: 2013.03.18 00:30:00

Even though I check SYMBOL_EXPIRATION_MODE:

Am I missing anything else?

PS: If I switch to ORDER_TIME_GTC, order goes through without errors.

Can you show your code for order sending ?
 
angevoyageur:
Can you show your code for order sending ?

Sure:

            NewVolume = GetPositionSize(UpperEntry - UpperSL);
            if (!Trade.OrderOpen(_Symbol, order_type, NewVolume, 0, UpperEntry, UpperSL, UpperTP, type_time, expiration, "ChartPatternHelper"))
            {
               last_error = GetLastError();
               Output("StopLevel = " + DoubleToString(StopLevel, 8));
               Output("FreezeLevel = " + DoubleToString(FreezeLevel, 8));
               Output("type_time = " + IntegerToString(type_time));
               Output("Error Sending Buy " + order_type_string + ": " + IntegerToString(last_error) + " (" + Trade.ResultRetcodeDescription() + ")");
               Output("Volume = " + DoubleToString(NewVolume, LotDigits) + " Entry = " + DoubleToString(UpperEntry, _Digits) + " SL = " + DoubleToString(UpperSL, _Digits) + " TP = " + DoubleToString(UpperTP, _Digits) + " Bid/Ask = " + DoubleToString(Bid, _Digits) + "/" + DoubleToString(Ask, _Digits) + " Exp: " + TimeToString(expiration, TIME_DATE|TIME_SECONDS));
            }
 
Any ideas? Or shall I submit a bug report to service desk?
Get in touch with developers using Service Desk!
Get in touch with developers using Service Desk!
  • www.mql5.com
We therefore attach great importance to all user reports about issues in our programs and try to answer each one of them.
 
enivid:
Any ideas? Or shall I submit a bug report to service desk?
I wonder if your expiration date is not too close to the current date. Try with 10 minutes at least.
 
angevoyageur:
I wonder if your expiration date is not too close to the current date. Try with 10 minutes at least.
Oh, I've thought about that before. I've tried it with minutes, hours and even days. The result is all the same.
 

hi enivid

i use this coding, it work

MqlTradeRequest Request;
ZeroMemory(Request);
   Request.type_time= ORDER_TIME_SPECIFIED;
   Request.expiration = TimeCurrent()+PERIOD_M30*60;
 
jelam:

hi enivid

i use this coding, it work

Thanks for suggestion! It turns out MetaQuotes removed the following line:

   m_request.expiration = expiration;

From its OrderOpen() implementation in Trade.mqh standard library without removing expiration from the function's parameters. Pretty cruel bug.

Documentation on MQL5: Standard Library
Documentation on MQL5: Standard Library
  • www.mql5.com
Standard Library - Documentation on MQL5
 
enivid:

Thanks for suggestion! It turns out MetaQuotes removed the following line:

From its OrderOpen() implementation in Trade.mqh standard library without removing expiration from the function's parameters. Pretty cruel bug.

Could you report this bug to Service Desk ?
 
angevoyageur:
Could you report this bug to Service Desk ?
Have already done so. They said that they fixed it.
Reason: