MT4 error 4105: No order selected (ERR_NO_ORDER_SELECTED)
You called an Order function such as OrderTicket() without a successful OrderSelect() first. Select the order, then read it.
What it means
You see this code in GetLastError() in MQL4, raised inside the terminal.
MQL4 reads order data through a selected order. Functions like OrderTicket(), OrderLots() and OrderProfit() work on that selection.
If no order was selected, or the last OrderSelect() failed, they raise 4105.
Common causes
OrderSelect()not called, or its return value ignored.- A loop index that went past the last order.
- An order that closed between the selection and the read.
How to fix it
- Always check what
OrderSelect()returns before reading order data. - Loop from
OrdersTotal() - 1down to 0, so closing orders inside the loop doesn't skip any.
Example in MQL4:
for(int i = OrdersTotal() - 1; i >= 0; i--)
{
if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
continue; // nothing selected: don't read
if(OrderSymbol() == Symbol() && OrderMagicNumber() == 4711)
Print("ticket ", OrderTicket(), " lots ", OrderLots());
} Is it safe to retry?
After selecting the order correctly.
Could the order have executed?
No. It is a coding error in your program.
How Tickwire handles it
Tickwire treats it like MT5 10013, and the MT4 code stays in the message. See trade results.
Related codes
One API for MT4 and MT5
Clear trade outcomes, idempotent orders and an audit log. Read the error reference or the quickstart.