How to Fix MT5 Error 10022 (Invalid Order Expiration)
MT5 return code 10022 means the trade server rejected the order expiration. Check the pending order's time type first, then check the submitted date or timestamp against the broker's server clock. These are separate checks. An expiration can be in the future and still be invalid because the exact symbol does not support that expiration mode.
Steps to check
- Read the expiration modes for the exact broker symbol. Open Specification from Market Watch and find the permitted expiration settings. In an Expert Advisor, read SYMBOL_EXPIRATION_MODE and test the flag that corresponds to the requested mode. The symbol's flags and the numeric values of the request's time type are different enumerations.
- Check what the request is meant to do. ORDER_TIME_GTC is the good-till-canceled time type. ORDER_TIME_DAY is valid for the current trading day. ORDER_TIME_SPECIFIED uses a specified expiration timestamp, while ORDER_TIME_SPECIFIED_DAY sets expiration for a selected date. The date mode generally runs to the end of that date, with session-dependent timing if that moment falls outside trading hours.
- Compare the submitted expiration with broker server time in the same time basis. Include the date as well as the hour in your log so you can see whether the request crossed midnight. In MQL5, TimeCurrent returns the last known server time based on quote activity. If quotes have stopped, check how fresh that reference is before treating it as the present time.
- Log the exact symbol, request time type, expiration value and return code together. Reproduce the calculation on a demo request and check that the chosen mode and timestamp express the intended lifetime. If the broker offers only modes that would keep the pending order open for a different period, report that conflict instead of quietly switching the order to good till canceled.
- For an expiration change to an existing order, check its current status before retrying. If it has already filled, expired or been canceled, the original pending order is no longer available to edit. Record the correction and run a fresh demo precheck for the exact request you intend to send.
Worked example
Suppose a demo symbol permits only good till canceled and current trading day. The EA submits ORDER_TIME_SPECIFIED for 16:00 broker time, and the server clock is at 14:00. The timestamp is two hours in the future, but the symbol does not support that mode. Moving the timestamp to 17:00 would leave the same mismatch. If the strategy requires a precise cutoff, flag the unsupported setting and leave the request unsent.
Frequently asked questions
Can I get 10022 when my expiration is in the future?
Yes. A symbol can reject the requested time type even when the timestamp is in the future. Compare that type with the symbol's supported modes first.
Are current trading day and specified day the same?
The current trading day mode applies to the session's current trading day. Specified day applies to a chosen date, with the expiration timing subject to the trading session.
Why does an expiration look valid on my PC but fail on MT5?
The time shown on your PC can differ from the broker's server time. Convert the date and time to the server's time basis before submitting and log the exact value sent.
Related guides
Related video
Related MT5 troubleshooting example: invalid stops (10016)