Skip to content

Trade Server Return Codes

Return Codes of the Trade Server

All requests to execute trade operations are sent as a structure of a trade request MqlTradeRequest using function OrderSend(). The function execution result is placed to structure MqlTradeResult, whose retcode field contains the trade server return code.

CodeConstantDescription
10004TRADE_RETCODE_REQUOTERequote
10006TRADE_RETCODE_REJECTRequest rejected
10007TRADE_RETCODE_CANCELRequest canceled by trader
10008TRADE_RETCODE_PLACEDOrder placed
10009TRADE_RETCODE_DONERequest completed
10010TRADE_RETCODE_DONE_PARTIALOnly part of the request was completed
10011TRADE_RETCODE_ERRORRequest processing error
10012TRADE_RETCODE_TIMEOUTRequest canceled by timeout
10013TRADE_RETCODE_INVALIDInvalid request
10014TRADE_RETCODE_INVALID_VOLUMEInvalid volume in the request
10015TRADE_RETCODE_INVALID_PRICEInvalid price in the request
10016TRADE_RETCODE_INVALID_STOPSInvalid stops in the request
10017TRADE_RETCODE_TRADE_DISABLEDTrade is disabled
10018TRADE_RETCODE_MARKET_CLOSEDMarket is closed
10019TRADE_RETCODE_NO_MONEYThere is not enough money to complete the request
10020TRADE_RETCODE_PRICE_CHANGEDPrices changed
10021TRADE_RETCODE_PRICE_OFFThere are no quotes to process the request
10022TRADE_RETCODE_INVALID_EXPIRATIONInvalid order expiration date in the request
10023TRADE_RETCODE_ORDER_CHANGEDOrder state changed
10024TRADE_RETCODE_TOO_MANY_REQUESTSToo frequent requests
10025TRADE_RETCODE_NO_CHANGESNo changes in request
10026TRADE_RETCODE_SERVER_DISABLES_ATAutotrading disabled by server
10027TRADE_RETCODE_CLIENT_DISABLES_ATAutotrading disabled by client terminal
10028TRADE_RETCODE_LOCKEDRequest locked for processing
10029TRADE_RETCODE_FROZENOrder or position frozen
10030TRADE_RETCODE_INVALID_FILLInvalid order filling type
10031TRADE_RETCODE_CONNECTIONNo connection with the trade server
10032TRADE_RETCODE_ONLY_REALOperation is allowed only for live accounts
10033TRADE_RETCODE_LIMIT_ORDERSThe number of pending orders has reached the limit
10034TRADE_RETCODE_LIMIT_VOLUMEThe volume of orders and positions for the symbol has reached the limit
10035TRADE_RETCODE_INVALID_ORDERIncorrect or prohibited order type
10036TRADE_RETCODE_POSITION_CLOSEDPosition with the specified POSITION_IDENTIFIER has already been closed
10038TRADE_RETCODE_INVALID_CLOSE_VOLUMEA close volume exceeds the current position volume
10039TRADE_RETCODE_CLOSE_ORDER_EXISTA close order already exists for a specified position. This may happen when working in the hedging system:

- when attempting to close a position with an opposite one, while close orders for the position already exist
- when attempting to fully or partially close a position if the total volume of the already present close orders and the newly placed one exceeds the current position volume
10040TRADE_RETCODE_LIMIT_POSITIONSThe number of open positions simultaneously present on an account can be limited by the server settings. After a limit is reached, the server returns the TRADE_RETCODE_LIMIT_POSITIONS error when attempting to place an order. The limitation operates differently depending on the position accounting type:

- Netting — number of open positions is considered. When a limit is reached, the platform does not let placing new orders whose execution may increase the number of open positions. In fact, the platform allows placing orders only for the symbols that already have open positions. The current pending orders are not considered since their execution may lead to changes in the current positions but it cannot increase their number.
- Hedging — pending orders are considered together with open positions, since a pending order activation always leads to opening a new position. When a limit is reached, the platform does not allow placing both new market orders for opening positions and pending orders.
10041TRADE_RETCODE_REJECT_CANCELThe pending order activation request is rejected, the order is canceled
10042TRADE_RETCODE_LONG_ONLYThe request is rejected, because the “Only long positions are allowed” rule is set for the symbol (POSITION_TYPE_BUY)
10043TRADE_RETCODE_SHORT_ONLYThe request is rejected, because the “Only short positions are allowed” rule is set for the symbol (POSITION_TYPE_SELL)
10044TRADE_RETCODE_CLOSE_ONLYThe request is rejected, because the “Only position closing is allowed” rule is set for the symbol
10045TRADE_RETCODE_FIFO_CLOSEThe request is rejected, because “Position closing is allowed only by FIFO rule” flag is set for the trading account (ACCOUNT_FIFO_CLOSE=true)
10046TRADE_RETCODE_HEDGE_PROHIBITEDThe request is rejected, because the “Opposite positions on a single symbol are disabled” rule is set for the trading account. For example, if the account has a Buy position, then a user cannot open a Sell position or place a pending sell order. The rule is only applied to accounts with hedging accounting system (ACCOUNT_MARGIN_MODE=ACCOUNT_MARGIN_MODE_RETAIL_HEDGING).
Last updated on