MT4 error 3: Invalid trade parameters (ERR_INVALID_TRADE_PARAMETERS)
The trade function got parameters that don't make sense, such as a wrong order type or a bad ticket. Nothing was executed.
What it means
You see this code in GetLastError() in MQL4, after a trade function fails on the server side.
Error 3 means the arguments to the trade function don't form a valid request. The server or terminal refused it as written.
It is usually a bug in how the request was built, not a market condition.
Common causes
- An order type that doesn't match the price, such as
OP_BUYwith the Bid. OrderClose()on a pending order. Pending orders needOrderDelete().- A negative or zero lot size, or a negative slippage.
- A ticket that belongs to another symbol or account.
How to fix it
- Buy at
Ask, sell atBid, and close a buy atBidand a sell atAsk. - Use
OrderDelete()for pending orders andOrderClose()for market orders. - Print every argument before the call while you debug.
Example in MQL4:
if(OrderSelect(ticket, SELECT_BY_TICKET))
{
bool ok;
if(OrderType() == OP_BUY)
ok = OrderClose(ticket, OrderLots(), Bid, 3);
else if(OrderType() == OP_SELL)
ok = OrderClose(ticket, OrderLots(), Ask, 3);
else
ok = OrderDelete(ticket); // pending orders are deleted
if(!ok) Print("failed, error ", GetLastError());
} Is it safe to retry?
After you fix the parameters.
Could the order have executed?
No. The request was invalid.
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.