MT4 error 4108: Invalid ticket (ERR_INVALID_TICKET)

The ticket number doesn't match an order the trade function can act on. It may be closed, deleted, or never existed.

4108ERR_INVALID_TICKET
After a fixSafe to retry?
NoCould it have executed?

What it means

You see this code in GetLastError() in MQL4, raised inside the terminal.

The trade function got a ticket it can't use. The order may have closed already, or the number is wrong.

Tickets are numbers you must keep from OrderSend() or read from OrderTicket().

Common causes

  • An order that closed by stop loss or take profit before your close.
  • A ticket kept in a variable after a restart, when the order is gone.
  • A -1 from a failed OrderSend() used as a ticket.

How to fix it

  • Select the order with OrderSelect(ticket, SELECT_BY_TICKET) and check OrderCloseTime() before acting.
  • Read open orders again after a restart instead of trusting saved numbers.

Example in MQL4:

if(!OrderSelect(ticket, SELECT_BY_TICKET))
   Print("No such ticket ", ticket);
else if(OrderCloseTime() > 0)
   Print("Ticket ", ticket, " is already closed");
else if(!OrderClose(ticket, OrderLots(), OrderType() == OP_BUY ? Bid : Ask, 3))
   Print("close failed, error ", GetLastError());

Is it safe to retry?

Only with a ticket that is still open.

Could the order have executed?

Not by this call. The order may have closed on its own earlier.

How Tickwire handles it

Tickwire treats it like MT5 10013, and the MT4 code stays in the message.

Tickwire checks that the position or order exists before sending. If not, you get numericCode 4753 or 4754 and nothing is sent. Read routes answer position_not_found or order_not_found.

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.