Invalid Expiration OrderSend expert

 

Hi .

I'm beginner in MQL5. I am trying to create OrderSend expert.

I write this code :

int OnInit()
{
    MqlTradeRequest request ;
    MqlTradeResult result ;

    request.action = TRADE_ACTION_PENDING;
    request.type = ORDER_TYPE_BUY_LIMIT;
    request.symbol = _Symbol;
    request.volume = 100 ;

    request.price = 45400  ;
    request.sl = request.price - (request.price*0.1);
    request.tp = request.price + (request.price*0.2);
    request.expiration = D'2021.10.10 13:00:00';
    request.type_filling = ORDER_FILLING_RETURN ;

    OrderSend(request,result);

    return(INIT_SUCCEEDED);
} 

But when run I am getting this expert error :

" 2021.10.01 00:00:00   failed buy limit 100 [my symbol] at 45400 sl: 40860 tp: 54480 [Invalid expiration]"

In Strategy Tester window I enter custom period from 2021.10.01 to 2021.10.20. I also tried my hard and select different date but not worked anything.

Any advise will be appreciated!

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
What are the differences between the three modes of testing in MetaTrader 5, and what should be particularly looked for? How does the testing of an EA, trading simultaneously on multiple instruments, take place? When and how are the indicator values calculated during testing, and how are the events handled? How to synchronize the bars from different instruments during testing in an "open prices only" mode? This article aims to provide answers to these and many other questions.
 

You have to check whether the Symbol allows such orders - look into the specification:

https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants#symbol_expiration_mode

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Symbol Properties
  • www.mql5.com
Symbol Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5