MT5 error 10042: Only long positions are allowed (TRADE_RETCODE_LONG_ONLY)

The symbol only allows buy positions right now. A sell was refused and nothing executed; a buy or a close will still work.

10042TRADE_RETCODE_LONG_ONLY
NoSafe to retry?
NoCould it have executed?

What it means

You see this code in the retcode of a trade result, from OrderSend() in MQL5 or order_send() in Python.

The broker has set the symbol to long only. You can open buys and close what you hold, but not open a new sell.

Brokers use this for instruments that can't be shorted, or during special conditions.

Common causes

  • A stock or crypto CFD that can't be sold short.
  • A temporary rule before a corporate action or a rollover.

How to fix it

  • Check symbol_info(name).trade_mode before sending. 1 means long only.
  • Skip sell signals on that symbol while the rule applies.

Example in Python:

import MetaTrader5 as mt5

mode = mt5.symbol_info("BTCUSD").trade_mode
if mode == 1:          # long only
    print("sells are not allowed on BTCUSD right now")

Is it safe to retry?

Not as a sell. The rule is a setting and stays until the broker changes it.

Could the order have executed?

No. The sell was refused.

How Tickwire handles it

Tickwire checks the symbol's trade mode before sending, so a sell on a long only symbol is refused with 10042 and nothing is sent.

MT4 error 140 and MT4 runtime error 4111 come back as 10042.

All MetaTrader error codes

One API for MT4 and MT5

Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.