Error Codes from Metatrader and MQL and Forex. Solutions.

Decompilation ex4 to mq4 is it necessary? Ex5 To Mq5 Decompiler. Ex4 to Mql4 converter
InfoPad, Online Information Panel for MetaTrader
Decompilation ex4 to mq4 is it necessary? Ex5 To Mq5 Decompiler. Ex4 to Mql4 converter
InfoPad, Online Information Panel for MetaTrader

Description

Error Codes

Error Codes in MetaTrader are crucial for identifying and resolving issues in the platform’s operations. The function GetLastError() retrieves these codes, and constants for these errors are defined in the stderror.mqh file.

To output descriptive text messages, the ErrorDescription() function, located in stdlib.mqh, can be used.

Errors may originate from the trade server or the client terminal.

As a specialist in MT4 and MT5 advisor programming, I frequently receive questions about such errors.

In response, I will explain the most common mistakes made by traders and Expert Advisors, their causes, and how to resolve them.

Every Expert Advisor operates differently, but many issues arise from a common set of problems.

Let’s explore the typical errors and their solutions, following the style of “Guidelines for Electronic Engineering Errors.”

A concise list of these errors can be found in the Error Codes reference, as well as in the MetaTrader 4/MetaTrader 5 terminal. We will use these resources to diagnose and solve problems effectively.

If your error isn’t listed or the suggested solutions don’t work, it’s advisable to contact the author of your Expert Advisor.

Before doing so, however, be sure to review the log files for further details about the issue.

Also i recommend read our FAQ

Some articles may also help you:

  1. FAQ: Answers to the most popular questions
  2. Testing and Optimization of Expert Advisors
  3. How to Install an Expert Advisor

Common Errors and How to Solve Them

Error NumberBrief DescriptionPossible CausesSolution Method
Graph Mismatch ErrorsErrors on the DC server: incoming ticks are not processed accurately across all timeframes. 1. The DC server inaccurately processes incoming ticks across various timeframes. 1. Testing immediately after loading from the archive does not reveal errors, as only minute data is loaded. Mismatches accumulate when live quotes start arriving.
TestGenerator: Unmatched Data ErrorError in the quotes archive data 1. Incomplete data from your broker
2. Corrupted quote database
3. Testing the EA using outdated data
4. Asynchronous data from older timeframes
An error occurs either when the data mismatch is not defined or when there is none.
Error 0 or 1No error or the error is unknown 1. Previous unresolved errors from a persistent request Do not handle errors 0 and 1 in the Expert Advisor.
Error 4, 146
(10022 in MT5)
The broker prohibits the use of an order expiration date1. The trade server is busy

2. You have set the wrong expiration type of the pending order (order cancellation time)
1. Restart the terminal
Optimize the EA code with better error handling functions

2. StopOrderDayToExpiration:
– 0 – ORDER_TIME_GTC The order will be in the queue until it is removed ;
– 1 – ORDER_TIME_DAY The order will be valid only for the current trading day; 
– X – ORDER_TIME_SPECIFIED The order will remain valid until the expiry date. 

or StopOrderBarToExpiration
Error 8, 141
(10024 in MT5)
Too Frequent Requests 1. The EA sends too many orders simultaneously
2. The EA does not wait for a server response before sending a new order, causing server overload
1. Ensure the EA waits for responses before sending additional orders.

2. Expert Advisor has sent too many requests. Please wait a bit and continue working with Expert Advisor.
Error 130, 145
(10016 in MT5)
Incorrect Stop Levels Specified Stop levels (StopLoss, TakeProfit) are too close to the current price 1. Verify the opening rules with your broker for Minimal StopLevel
2. Ensure stop levels comply with your account and broker’s specifications
3. You can use our function:
SetMinStops Automatically normalize all parameters of the Expert Advisor to the minimum acceptable stop levels
4. Please set higher level of Stop parametrs StopLoss, TakeProfit, TrailingStop, Order Distance ….
Error 132
(10018 in MT5)
The Market is ClosedThe market is closed, usually on weekendsTry placing the trade after the market reopens.
To trade in weekends you can try our TesterPad
Error 133
(10017 in MT5)
Trading is Prohibited 1. Trading is currently restricted
2. Trading is prohibited for the selected currency pair
1. Wait for trading to resume

2. Try trading a different currency pair or check if a suffix is required for your pair
Error 134
(10019 in MT5)
Not Enough Funds to Complete the Transaction 1. The lot size you are trying to open is too large, leading to insufficient margin 1. Check your free margin
2. Calculate the necessary funds for the desired lot size before opening the position
3. Check your trading lot settings (Lot, Autolot, DynamicLot, Martin)
Error 135–138
(10004, 10006, 10020 in MT5)
The Price Has Changed 1. Requote occurred
2. Market volatility
3. Broker does not allow trades at the stated price
1. Avoid trading during volatile market periods
2. Increase slippage, but be aware that this may result in trades executed at different prices
3. This is a standard mistake of the fast market.
Error 147ERR TRADE EXPIRATION DENIEDThe EA or user attempts to set a pending order expiration dateSet the expiration date to 0 in the OrderSend function of the EA.

The use of order expiration date is prohibited by the broker
Error 148
(10033 in MT5)
Maximum Open or Pending Orders ReachedThe maximum limit of open orders or pending positions has been reached Check your broker’s limit for open orders and adjust your trading strategy accordingly.
Error 4012, 4013Division by Zero

Zero Devide
1. The EA attempts to divide by zero in its calculations
2. MarketInfo(Symbol(), MODE_SPREAD) may return zero for brokers with floating spreads
Check the EA code to prevent division by zero and ensure proper handling of MarketInfo responses.
Error 4017DLL Call Not AllowedCalling a DLL is prohibited by the terminal or antivirus software1. Allow DLL calls through the terminal settings
2. Ensure the DLL is safe using antivirus software before enabling it
Error 4106Unknown SymbolThe symbol is not listed in the Market WatchEnable the symbol in Market Watch or request it from your broker.

Error 4108
(10036 in MT5)
Invalid Ticket NumberThe order’s ticket number no longer exists
The order may have been closed manually or by another EA
Avoid manual intervention in EA-managed orders and disable conflicting EAs.

Perhaps the Expert Advisor is trying to close or modify an order that has already been closed by another Expert Advisor.
Error 4110, 4111
(10042,10043,10044 in MT5)
Long/Short Positions Not AllowedThe EA settings restrict certain trade types

Server limit type of position
Adjust the settings in the General tab to allow the desired trade types (Long & Short, Only Long, Only Short for MT4 only).

Ask your broker
Error 10030TRADE RETCODE INVALID FILLIncorrect filling of orders.Set the parameter in the Expert Advisor settings
TypeFilling
The type of fill positions and orders. 
It is used for the MT5 terminal. 
In AUTO mode, the Expert Advisor tries to determine the fill type automatically. 
But, in some situations, you need to set the fill type yourself. 

TRADE ERROR CODES

Error Codes Returned from the Trade Server

The CodeIdentifierDescriptionSolution Method
10004TRADE_RETCODE_REQUOTERequoteIncrease the slippage level or avoid trading during high volatility periods.

Slippage
The level of the maximum possible deviation in price when opening and closing positions (in Points). 
10006TRADE_RETCODE_REJECTRequest DeniedCheck the trade conditions and account status, and retry the request later.
10007TRADE_RETCODE_CANCELRequest Canceled by TraderEnsure that no manual cancellation is occurring or adjust the EA settings.
10008TRADE_RETCODE_PLACEDOrder PlacedNo action required. This is a confirmation message.
10009TRADE_RETCODE_DONEApplication CompletedNo action required. The request has been successfully completed.
10010TRADE_RETCODE_DONE_PARTIALApplication Partially CompletedCheck the remaining order and complete it manually if necessary.
10011TRADE_RETCODE_ERRORRequest Processing ErrorReview the logs to identify the error and retry the request after correction.
10012TRADE_RETCODE_TIMEOUTRequest Canceled Due to TimeoutIncrease the timeout period or retry during periods of lower server load.
10013TRADE_RETCODE_INVALIDBad RequestCheck the request parameters and retry with correct values.
10014TRADE_RETCODE_INVALID_VOLUMEIncorrect Volume in the RequestEnsure the trade volume is within the allowable limits for the account.
10015TRADE_RETCODE_INVALID_PRICEWrong Price in the RequestCheck the market price and retry with the correct one.
10016TRADE_RETCODE_INVALID_STOPSWrong Stops in the RequestEnsure that the StopLoss and TakeProfit values comply with broker rules.

SetMinStops
Automatically normalize all parameters of the Expert Advisor to the minimum acceptable stop levels. 
10017TRADE_RETCODE_TRADE_DISABLEDTrade ProhibitedCheck the trading conditions on the account and broker’s restrictions.
10018TRADE_RETCODE_MARKET_CLOSEDThe Market is ClosedWait until the market reopens to place a trade.

To trade in weekends you can try our TesterPad
10019TRADE_RETCODE_NO_MONEYNot Enough Funds to Fulfill the RequestEnsure sufficient funds in the account or reduce the trade size.
10020TRADE_RETCODE_PRICE_CHANGEDPrices Have ChangedRetry the request with the updated price or increase slippage allowance.
10021TRADE_RETCODE_PRICE_OFFNo Quotes to Process RequestWait for the market to provide quotes and retry the request.
10022TRADE_RETCODE_INVALID_EXPIRATIONInvalid Order Expiration Date in the RequestSet the correct expiration date or leave it blank for immediate orders.

StopOrderDay ToExpiration = number of days for the order expiration.
10023TRADE_RETCODE_ORDER_CHANGEDOrder Status Has ChangedUpdate the order status and retry the request with the correct information.
10024TRADE_RETCODE_TOO_MANY_REQUESTSToo Frequent RequestsLimit the number of requests per second to avoid overloading the server.
10025TRADE_RETCODE_NO_CHANGESNo Changes in the RequestEnsure there are actual changes before resubmitting the request.
10026TRADE_RETCODE_SERVER_DISABLES_ATAsk your broker
10027TRADE_RETCODE_CLIENT_DISABLES_ATThe Client Terminal Prohibits Auto TradingEnable auto trading in the terminal settings to proceed with trades.


10028TRADE_RETCODE_LOCKEDThere is Already a Closing Order for the Specified Position. It May Occur When Working in a Hedging System

Request Blocked for Processing
Wait for the current closing order to process before submitting another.

Check for locked orders or system restrictions and resolve the issue.
10029TRADE_RETCODE_FROZENOrder or Position is FrozenContact your broker to understand why the position is frozen.
10030TRADE_RETCODE_INVALID_FILLAn Unsupported Order Execution Type by Balance was SpecifiedEnsure the correct order execution type is chosen for your balance.
TypeFilling

The type of fill positions and orders. 
It is used for the MT5 terminal. 
In AUTO mode, the Expert Advisor tries to determine the fill type automatically. 
But, in some situations, you need to set the fill type yourself. 
10031TRADE_RETCODE_CONNECTIONThe Request to Activate a Pending Order was Rejected, and the Order Itself was CanceledCheck the connection to the server and retry the request.
10032TRADE_RETCODE_ONLY_REALThe Operation is Allowed Only for Real AccountsEnsure the operation is being conducted on a real account, not a demo account.
10033TRADE_RETCODE_LIMIT_ORDERSThe Limit on the Number of Pending Orders has Been ReachedReduce the number of pending orders or contact the broker for adjustments.
10034TRADE_RETCODE_LIMIT_VOLUMEThe Limit on the Volume of Orders and Positions for This Symbol has Been ReachedReduce the trade volume or contact the broker for adjustments.
10035TRADE_RETCODE_INVALID_ORDERInvalid or Prohibited Order TypeCheck the allowed order types for the broker and retry with a valid type.
10036TRADE_RETCODE_POSITION_CLOSEDPosition with Specified POSITION_IDENTIFIER is Already ClosedNo action needed. The position has already been closed.
10038TRADE_RETCODE_INVALID_CLOSE_VOLUMEClosed Volume Exceeds Current Position VolumeEnsure the volume to close does not exceed the current position size.
10039TRADE_RETCODE_CLOSE_ORDER_EXISTNo Connection to the Trade ServerCheck the connection and reattempt once the server is reachable.
10040TRADE_RETCODE_LIMIT_POSITIONSThe Request was Rejected Because the Symbol is Set to the Rule “You Can Only Close Existing Positions.”Close existing positions before attempting new ones.
10041TRADE_RETCODE_REJECT_CANCELThe Request was Rejected Because the Symbol is Set to the Rule “You Can Only Close Existing Positions.”Adjust the trade to comply with the “close-only” rule.
10042TRADE_RETCODE_LONG_ONLYThe Request was Rejected Because the Rule “Only Long Positions Allowed” is Set on the SymbolOnly long positions are allowed for this symbol; avoid submitting short trades.
10043TRADE_RETCODE_SHORT_ONLYThe Request was Rejected Because the Rule “Only Short Positions Allowed” is Set on the SymbolOnly short positions are allowed for this symbol; avoid submitting long trades.
10044TRADE_RETCODE_CLOSE_ONLYThe Request was Rejected Because the Symbol is Set to the Rule “You Can Only Close Existing Positions”Comply with the “close-only” rule by closing positions instead of opening new ones.

Other Errors

Error CodeError NumberDescriptionSolution Method
ERR_SUCCESS0Operation Completed SuccessfullyNo action required.
ERR_INTERNAL_ERROR4001Unexpected Internal ErrorCheck for system or program conflicts and restart the terminal.
ERR_WRONG_INTERNAL_PARAMETER4002The Structure Contains Invalid Objects Like Strings, Dynamic Arrays, or Unsupported StructuresReview the structure of the objects and ensure they are properly defined.
ERR_INVALID_PARAMETER4003Wrong Parameter When Calling a System FunctionVerify the function’s parameters and ensure they match the required format.
ERR_NOT_ENOUGH_MEMORY4004Not Enough Memory to Execute a System FunctionFree up system memory or optimize the program to use less memory.
ERR_STRUCT_WITHOBJECTS_ORCLASS4005Not Enough Memory to Reallocate the StringCheck for memory leaks and optimize the program’s memory usage.
ERR_INVALID_ARRAY4006An Array of the Wrong Type, Size, or a Broken Dynamic Array ObjectEnsure the array is correctly defined and initialized before use.
ERR_ARRAY_RESIZE_ERROR4007The Requested Array Size Exceeds 2 GigabytesReduce the array size or manage memory allocation more efficiently.
ERR_STRING_RESIZE_ERROR4008The Requested History was Not FoundEnsure the requested history is available or adjust the request parameters.
ERR_NOTINITIALIZED_STRING4009Uninitialized StringInitialize the string before attempting to use it in operations.
ERR_INVALID_DATETIME4010Wrong Date and/or Time ValueVerify the date and time format in the request and retry.
ERR_ARRAY_BAD_SIZE4011Mismatched Dynamic and Static ResourcesEnsure the array sizes are compatible and correctly initialized.
ERR_INVALID_POINTER4012Wrong PointerCheck the pointer value and ensure it’s valid before use.
ERR_INVALID_POINTER_TYPE4013Wrong Pointer TypeEnsure the pointer is of the correct type and properly cast.
ERR_FUNCTION_NOT_ALLOWED4014System Function Not Allowed to be CalledReview system restrictions and confirm the function can be executed.
ERR_RESOURCE_NAME_DUPLICATED4015Duplicate Resource NameUse unique resource names to avoid conflicts.
ERR_RESOURCE_NOT_FOUND4016No Resource Found with the Specified NameEnsure the resource exists in the correct directory or file.
ERR_RESOURCE_UNSUPPOTED_TYPE4017Unsupported Resource Type or Size Exceeds 16 MBUse supported resource types and ensure the size is under the limit.
ERR_RESOURCE_NAME_IS_TOO_LONG4018Resource Name Exceeds 63 CharactersShorten the resource name to meet the character limit.
ERR_MATH_OVERFLOW4019Overflow Occurred While Evaluating a Math FunctionCheck the function inputs and use smaller values to prevent overflow.
ERR_CHART_WRONG_ID4101Wrong Chart IDVerify the chart ID and ensure it’s correct before using it.
ERR_CHART_NO_REPLY4102Chart Not RespondingCheck for system or connection issues and restart the terminal if necessary.
ERR_CHART_NOT_FOUND4103Chart Not FoundEnsure the chart is open and accessible before attempting operations.
ERR_CHART_NO_EXPERT4104No Expert is Available to Process the Event on the ChartAttach the necessary Expert Advisor (EA) to the chart to handle events.
ERR_CHART_CANNOT_OPEN4105Chart Opening ErrorCheck for system errors and retry opening the chart.
ERR_CHART_CANNOT_CHANGE4106Error Changing Symbol or Period on the ChartEnsure the chart is accessible and that the requested symbol or period is valid.
ERR_CHART_WRONG_PARAMETER4107Wrong Parameter Value for the Chart FunctionVerify the parameters being passed to the chart function and retry.
ERR_CHART_CANNOT_CREATE_TIMER4108Error Creating Chart TimerCheck the system settings and ensure the terminal allows timer creation.
ERR_CHART_WRONG_PROPERTY4109Wrong Chart Property IDUse the correct property ID for chart operations.
ERR_CHART_SCREENSHOT_FAILED4110Error Taking a ScreenshotEnsure the terminal has sufficient permissions and storage space to save the screenshot.
ERR_CHART_NAVIGATE_FAILED4111Chart Navigation ErrorEnsure the chart is loaded correctly and that navigation commands are valid.
ERR_CHART_TEMPLATE_FAILED4112Error Applying TemplateEnsure the template exists and is compatible with the chart.
ERR_CHART_WINDOW_NOT_FOUND4113The Subwindow Containing the Specified Indicator was Not FoundCheck if the indicator is applied to the correct window.
ERR_CHART_INDICATOR_CANNOT_ADD4114Error Adding an Indicator to a ChartEnsure the indicator is valid and supported by the chart.
ERR_CHART_INDICATOR_CANNOT_DEL4115Error Deleting an Indicator from a ChartEnsure the indicator exists on the chart before attempting to delete it.
ERR_CHART_INDICATOR_NOT_FOUND4116The Indicator was Not Found on the Specified ChartVerify the chart and indicator parameters and retry.
ERR_OBJECT_ERROR4201The Terminal Settings Limit the Number of Requested BarsIncrease the number of bars allowed in the terminal settings.
ERR_OBJECT_NOT_FOUND4202Graphic Object Not FoundEnsure the graphic object exists and is correctly defined.
ERR_OBJECT_WRONG_PROPERTY4203Wrong Graphic Object Property IdentifierUse the correct property identifier for graphic object operations.
ERR_OBJECT_GETDATE_FAILED4204Access to History FailedCheck the history access permissions and retry the request.
ERR_OBJECT_GETVALUE_FAILED4205Unable to Get Value Corresponding to DateVerify the date range and ensure the history data is available.
ERR_MARKET_UNKNOWN_SYMBOL4301Unknown SymbolEnsure the symbol exists in the Market Watch and is spelled correctly.
ERR_MARKET_NOT_SELECTED4302Symbol Not Selected in Market WatchSelect the symbol in Market Watch and retry the operation.
ERR_MARKET_WRONG_PROPERTY4303Wrong Symbol Property IdentifierVerify the property identifier and retry the operation.
ERR_MARKET_LASTTIME_UNKNOWN4304The Time of the Last Tick is Unknown (There Were No Ticks)Wait for a tick to arrive and retry the request.
ERR_MARKET_SELECT_ERROR4305Error Adding or Removing Symbol in Market WatchCheck for system errors and retry adding or removing the symbol.
ERR_HISTORY_NOT_FOUND4401Many Errors Occurred When Loading HistoryCheck for corrupted history data and reload the history if necessary.
ERR_HISTORY_WRONG_PROPERTY4402Incorrect History Property IdentifierUse the correct property identifier for history operations.
ERR_HISTORY_TIMEOUT4403Timeout Exceeded When Requesting HistoryIncrease the timeout limit or retry during periods of lower system load.
ERR_GLOBALVARIABLE_NOT_FOUND4501Client Terminal Global Variable Not FoundEnsure the global variable exists before attempting to use it.
ERR_GLOBALVARIABLE_EXISTS4502Global Variable Already ExistsUse a unique name for global variables to avoid conflicts.
ERR_GLOBALVARIABLE_NOT_MODIFIED4503No Modifications Were Made to the Global VariableEnsure the global variable is modified before attempting to update it.
ERR_GLOBALVARIABLE_CANNOTREAD4504Failed to Read Global Variable ValueCheck file permissions and ensure the global variable is accessible.
ERR_GLOBALVARIABLE_CANNOTWRITE4505Failed to Write Global Variable ValueEnsure there is sufficient permission and storage space to write the file.
ERR_MAIL_SEND_FAILED4510Failed to Send an EmailCheck email server settings and ensure the email address is correct.
ERR_PLAY_SOUND_FAILED4511Failed to Play SoundEnsure the sound file exists and the system can access it.
ERR_FTP_SEND_FAILED4514No FTP Server is SpecifiedEnsure the FTP server details are entered correctly and retry.
ERR_NOTIFICATION_SEND_FAILED4515Failed to Send NotificationVerify the notification settings and ensure they are correctly configured.
ERR_BUFFERS_NO_MEMORY4601Not Enough Memory to Allocate Indicator BuffersFree up memory or optimize buffer usage in the program.
ERR_ACCOUNT_WRONG_PROPERTY4701Wrong Account Property IDEnsure the correct account property ID is being used.
ERR_TRADE_DISABLED4752Trading for an Expert is ProhibitedEnable trading permissions for the Expert Advisor in the terminal.
ERR_TRADE_POSITION_NOT_FOUND4753Position Not FoundVerify the position details and ensure it exists before attempting operations.
ERR_TRADE_ORDER_NOT_FOUND4754Order Not FoundVerify the order ID and ensure it exists before attempting operations.

MARKET MQL5 Errors

Questions?

If you have any questions, please ask them. We ensure transparency and do not sell products without providing full information.

Each of our products can be reviewed before purchase.

We appreciate your interest and support for our products and strive to maintain high-quality standards.

Thank you for being with us!

Do you have a question?

Leave a Reply

Your email address will not be published. Required fields are marked *

This post is also available in: English Українська Portuguese Español Deutsch Chinese Русский Français Italiano Türkçe 日本語 한국어

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.


     

    Risk Warning:


    Past trading performance does not guarantee future results.

    Trading foreign exchange on margin carries a high degree of risk and may not be suitable for all investors.

    Be aware that using trading robots involves substantial risk, and you could lose more than your initial investment.

    Please proceed with caution, assess your financial situation carefully, and consider seeking advice from a qualified professional.

    Disclaimer

    This website uses cookies to improve your experience. By using this website you agree to our Data Protection Policy and Disclaimer.
    Read More