MT5 Python error -2: Invalid parameters (RES_E_INVALID_PARAMS)

The function got arguments of the wrong type or value, such as a volume passed as an int. Fix the call; nothing was sent.

-2RES_E_INVALID_PARAMS
After a fixSafe to retry?
NoCould it have executed?

What it means

You see this code in mt5.last_error() in Python, after a package call returns None or False.

The package checks argument types before it talks to the terminal. If an argument has the wrong type or an impossible value, the call fails with -2.

The package is strict about types. A volume must be a float, and tickets and counts must be ints.

Common causes

  • "volume": 1 instead of "volume": 1.0 in an order_send request.
  • A symbol passed as something other than a string.
  • A count of 0 or a negative number in a copy_* call.
  • A numpy type, such as numpy.float64, where a plain Python number is expected.

How to fix it

  • Cast values yourself: float(volume), int(ticket), str(symbol).
  • Convert numpy values with .item() or float() before building the request.
  • Print the request with the type of each value while you debug.

Example in Python:

import MetaTrader5 as mt5

request = {
    "action": mt5.TRADE_ACTION_DEAL,
    "symbol": str(symbol),
    "volume": float(lots),          # 1 would fail, 1.0 is fine
    "type": mt5.ORDER_TYPE_BUY,
    "price": float(mt5.symbol_info_tick(symbol).ask),
    "deviation": int(20),
}
print({k: type(v).__name__ for k, v in request.items()})
r = mt5.order_send(request)
if r is None:
    print(mt5.last_error())

Is it safe to retry?

Only after you fix the arguments.

Could the order have executed?

No. The call failed before anything reached the terminal's trade logic.

Without the Python package

With Tickwire your code calls a REST API from any operating system, so this package error doesn't come up. See the MT5 Python API page.

Related MT5 Python functions

All MetaTrader error codes

All MetaTrader5 Python functions

One API for MT4 and MT5

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