MT4 error 131: Invalid trade volume (ERR_INVALID_TRADE_VOLUME)

The lot size is below the minimum, above the maximum or off the lot step. Nothing was executed; round the volume and resend.

131ERR_INVALID_TRADE_VOLUME
After a fixSafe to retry?
NoCould it have executed?

What it means

You see this code in GetLastError() in MQL4, after a trade function fails on the server side.

Each MT4 symbol has a minimum lot, a maximum lot and a lot step. Error 131 means the volume broke one of them.

Limits can differ between account types, such as cent and standard accounts at the same broker.

Common causes

  • A risk formula that returns a volume below the minimum.
  • A volume like 0.015 when the step is 0.01.
  • Floating point leftovers that aren't a clean multiple of the step.

How to fix it

  • Read MODE_MINLOT, MODE_MAXLOT and MODE_LOTSTEP with MarketInfo().
  • Round down to the step and clamp to the limits.

Example in MQL4:

double ValidLots(string sym, double lots)
{
   double step = MarketInfo(sym, MODE_LOTSTEP);
   double minL = MarketInfo(sym, MODE_MINLOT);
   double maxL = MarketInfo(sym, MODE_MAXLOT);
   lots = MathFloor(lots / step + 1e-9) * step;
   if(lots < minL) return 0;               // too small: skip the trade
   return NormalizeDouble(MathMin(lots, maxL), 2);
}

Is it safe to retry?

After you fix the volume.

Could the order have executed?

No. A volume the symbol doesn't allow is refused before any order exists.

How Tickwire handles it

Tickwire treats it like MT5 10014, and the MT4 code stays in the message. See trade results.

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.