FX NOOKAI CODE LAB
Loading

MT4 Error 131: Diagnose Invalid Volume Step by Step

By FXNook Lab team

MT4 error 131 means the order request contains a volume the broker does not accept. The fix is to compare the exact lots sent by the EA with the traded symbol’s minimum volume, maximum volume and lot step, then correct the sizing calculation or reject the request before OrderSend. A volume can be valid on one symbol or account and invalid on another because these settings are broker- and symbol-specific.

Do not treat 131 as a general order failure. It points to volume, so changing stop-loss distance or slippage will not fix it. If you want a broader overview of the OrderSend error, see OrderSend Error 131: Fix Invalid Volume in MT4.

What MT4 error 131 means

Error 131 is ERR_INVALID_TRADE_VOLUME. It means MT4 sent an order with a lot size that the trade server rejected, commonly because the size is below the symbol’s minimum, above its maximum, or not a permitted increment of its lot step.

Find the error in the Experts or Journal tab at the bottom of MT4. In the Strategy Tester, use its Journal tab. Look for the message immediately after the EA’s order attempt: it may show the order parameters and the returned error, or only the error number. If the EA does not print the requested volume, add a log line just before OrderSend so you can match the failure to the exact symbol and lots.

For example, a broker may allow a symbol to trade from 0.10 lots, in 0.10-lot increments. An EA request for 0.13 lots is between the allowed steps and can return error 131, while 0.10 lots fits the stated minimum and step. The key is not to assume that a lot size accepted on another pair is valid here.

Inspect the traded symbol’s volume limits

In MT4, open Market Watch, right-click the exact symbol and choose Specification. Find the minimum volume, maximum volume and volume step. Labels can vary slightly by broker, but those are the three values the EA’s requested volume must satisfy.

Make sure you inspect the same symbol name that the EA passes to OrderSend. Brokers often add suffixes or prefixes, such as a symbol-specific ending, and the specification for the unsuffixed name may not match. If the symbol is not visible in Market Watch, use Show All or select the broker’s exact symbol before checking it.

In MQL4, an EA can read these values with MarketInfo:

double minLot  = MarketInfo(Symbol(), MODE_MINLOT);
double maxLot  = MarketInfo(Symbol(), MODE_MAXLOT);
double lotStep = MarketInfo(Symbol(), MODE_LOTSTEP);

For a multi-symbol EA, replace Symbol() with the exact symbol string being traded. Do not read the limits for the chart symbol and then use them to validate an order for a different instrument. A broker can set different volume rules for currency pairs, metals, indices and other instruments.

Compare the requested lots with the specification

Write down the three specification values and the requested size from the log. Then test the request against all three limits; being below the maximum is not enough if the lot step does not allow that exact value.

MismatchExampleWhat to check
Below minimumEA requests 0.01; minimum is 0.10Find where the sizing calculation reduces the volume below the symbol minimum.
Above maximumEA requests 50.00; maximum is 20.00Check risk sizing, input units and whether the EA applies a maximum-volume limit.
Not on the lot stepEA requests 0.13; minimum is 0.10 and step is 0.10Only permitted increments from the minimum are valid; 0.13 does not fit, while 0.10 does.
Wrong symbol’s limitsEA checks EURUSD but sends an order on a suffixed symbolUse the exact symbol sent to the trade server for both the limits and the order.
Rounded to decimal places onlyEA normalizes to two decimal places, but the step is 0.25Decimal formatting is not the same as checking multiples of the lot step.

In the 0.13 example, rounding to two decimal places leaves the value at 0.13, so it remains invalid. Even NormalizeDouble(lots, 2) only controls decimal precision; it does not make a volume conform to the broker’s step. Keep the requested value visible in logs, and decide deliberately whether your strategy should reject it or calculate a different valid size.

Validate volume before OrderSend in MQL4

The helper below reads the current symbol’s volume properties, checks the range and tests whether the request falls on a permitted step from the minimum. It logs why a request fails and returns false; it does not silently round or otherwise change the strategy’s requested size.

bool IsValidOrderVolume(string symbol, double lots)
{
   double minLot  = MarketInfo(symbol, MODE_MINLOT);
   double maxLot  = MarketInfo(symbol, MODE_MAXLOT);
   double lotStep = MarketInfo(symbol, MODE_LOTSTEP);

   if (minLot <= 0.0 || maxLot < minLot || lotStep <= 0.0)
   {
      Print("Cannot read valid volume settings for ", symbol,
            ". Min=", DoubleToString(minLot, 8),
            " Max=", DoubleToString(maxLot, 8),
            " Step=", DoubleToString(lotStep, 8));
      return false;
   }

   if (lots < minLot || lots > maxLot)
   {
      Print("Volume out of range for ", symbol,
            ". Requested=", DoubleToString(lots, 8),
            " Min=", DoubleToString(minLot, 8),
            " Max=", DoubleToString(maxLot, 8));
      return false;
   }

   double steps     = (lots - minLot) / lotStep;
   double nearest   = MathRound(steps);
   double tolerance = 1e-7 * MathMax(1.0, MathAbs(steps));

   if (MathAbs(steps - nearest) > tolerance)
   {
      Print("Volume does not match lot step for ", symbol,
            ". Requested=", DoubleToString(lots, 8),
            " Min=", DoubleToString(minLot, 8),
            " Step=", DoubleToString(lotStep, 8));
      return false;
   }

   return true;
}

Call the helper immediately before the order request, using the same symbol and volume that will be sent. This example belongs inside an EA function such as OnTick:

string symbol = Symbol();
double lots = 0.13;

if (!IsValidOrderVolume(symbol, lots))
   return;

RefreshRates();
Print("Sending order: symbol=", symbol,
      " lots=", DoubleToString(lots, 8));

int ticket = OrderSend(symbol, OP_BUY, lots, Ask, 3, 0, 0,
                       "Volume check", 12345, 0, clrNONE);

if (ticket < 0)
{
   int errorCode = GetLastError();
   Print("OrderSend failed: symbol=", symbol,
         " lots=", DoubleToString(lots, 8),
         " error=", errorCode);
}

This guard explains whether the request is outside the range or off-step before the EA calls OrderSend. The final error log still matters: the broker can reject an order for another reason, so capture the error code immediately and investigate that code rather than assuming every failure is volume-related.

Trace EA-specific volume calculations

An EA that sizes trades by risk often calculates lots from account balance, the chosen risk percentage, stop distance and the value of a tick. A common cause of error 131 is a calculation that assumes the same tick value, contract size or lot rules for every instrument. The resulting number may look plausible but still be below the minimum, above the maximum or incompatible with the step.

Inspect the units and inputs in the sizing formula. For example, a distance in points is not interchangeable with a distance in pips, and a tick value used for one instrument may not apply to another. Log the raw calculated lots, the final lots passed to OrderSend, the symbol and the three MarketInfo values. That separates a calculation problem from a later change in the EA’s order parameters.

Symbol suffixes can expose a related mistake. An EA may place an order on a broker’s suffixed symbol but read volume limits or other contract data using a hard-coded base name. Make the symbol used for the order, volume checks and relevant market data the same exact broker symbol. Also review any symbol-mapping code that selects a trade instrument from an input or chart name.

Do not use decimal rounding as a substitute for a volume policy. If the strategy requires a precise risk-based size that is not tradable, rejecting the request and logging the reason preserves that intent. If the strategy is designed to use the nearest lower valid size, implement that rule explicitly, check that it remains above the minimum, and make the result visible; never alter position size without deciding how that changes the strategy.

Distinguish error 131 from nearby errors

Error numbers identify different order problems. Verify the actual code in the Experts or Journal log before changing settings, because changing stops will not correct a volume mismatch.

MT4 errorMeaningFirst area to investigate
130ERR_INVALID_STOPSStop-loss or take-profit prices and the broker’s minimum stop distance.
131ERR_INVALID_TRADE_VOLUMERequested lots compared with the symbol’s minimum, maximum and step.
133ERR_TRADE_DISABLEDWhether trading is disabled for the symbol or by the broker or account.

An order can have more than one issue, and after you fix the first rejection another one may become visible. Still, diagnose the reported code first. If an EA reports 130, inspect stop settings; if it reports 133, investigate trading permission. Neither code is a reason to change the lot size without evidence.

Retest with the same symbol and conditions

  1. Log the request. Immediately before OrderSend, print the exact symbol, requested lots and order type. After failure, record the error code returned by GetLastError.
  2. Record the broker limits. Log MODE_MINLOT, MODE_MAXLOT and MODE_LOTSTEP for that exact symbol. Compare the values with the Specification window in Market Watch.
  3. Reproduce on the same instrument. Test the EA with the same broker symbol, including any suffix, and the relevant account conditions. A different symbol or account may have different volume settings.
  4. Use the Strategy Tester as a code check. Run a test that reaches the order logic and inspect the tester Journal for the requested size and error. Tester conditions may not reproduce all live broker restrictions, so compare its symbol data and settings with the trading account.
  5. Verify the live log. Once the EA is running, confirm that it no longer reports error 131 and that the logged order volume matches the intended sizing rule. A successful compile alone does not show that the broker will accept a live order.

If the EA still fails to open trades, the volume may only be one part of the problem. The MT4 EA not opening trades guide covers other order and execution checks.

Practical next step

Start with one failed order: copy its symbol and requested lots from the log, read that symbol’s minimum, maximum and step, and run the same values through a pre-order validation check. If the sizing path is difficult to follow or the EA has other trade-entry blockers, FXNook Lab’s EA debugger can inspect the program’s trading logic, run its checks and show what stops it from trading. For MQL4 compile problems in the validation code, use FXNook Lab’s MQL4/MQL5 error fixer.

Questions

What does error 131 mean in MT4?

Error 131 is MT4’s invalid trade volume error: the trade server rejected the lot size in the order request. Compare the requested volume with that symbol’s minimum, maximum and lot step.

How do I check the minimum lot size and lot step in MT4?

In Market Watch, right-click the broker’s exact symbol and open Specification to see its minimum volume, maximum volume and volume step. An EA can read the same properties with `MarketInfo(symbol, MODE_MINLOT)`, `MODE_MAXLOT` and `MODE_LOTSTEP`.

Why does my MT4 EA get error 131 on only one symbol?

Volume limits can differ between symbols, so a size accepted on one pair may be off-step or outside the limits on another. The EA may also be using sizing assumptions or volume settings from a different symbol, especially when the broker uses suffixes.

Should I round lots to the broker's lot step?

Only if the EA’s intended sizing rule explicitly allows that adjustment. Decimal rounding alone does not enforce the lot step; validate the resulting size and log it, or reject the request rather than silently changing the strategy’s volume.