Camovia Tray™

Blog · Knowledge

Handling OrderSend Error 131 in MetaTrader 4: Why It Happens and How to Fix It

Camovia Tray Team · 2026-09-15

You've just coded what you believe is a perfect Expert Advisor—logic is sound, entry signals are crisp, risk parameters are dialed in. You hit "Start" on the Strategy Tester, expecting a smooth backtest. Instead, the Journal tab spits out a familiar frustration: OrderSend error 131. Or worse—you've deployed the EA on a live demo, everything seems to be running, but no trades are opening, and the error keeps appearing.

You might be thinking: Is this a broker issue? A code bug? Did I miss something fundamental? The answer is usually simpler—and more fixable—than you'd expect.

What Exactly Is OrderSend Error 131?

In MQL4, error 131 has a specific and unambiguous definition: ERR_INVALID_TRADE_VOLUME—"Invalid volume" . It means the lot size your EA sent to the OrderSend() or OrderClose() function didn't meet the broker's requirements for that instrument at that moment.

But "invalid" can mean several different things depending on your broker, account type, and the code itself. Let's break down the real reasons behind this error, starting with the most common one.

The Real Reasons Behind Error 131

Reason 1: Your Lot Size Falls Outside the Allowed Range (and You Didn't Check It)

This is the number one culprit. Each trading instrument on MT4 has a minimum lot size (MODE_MINLOT), a maximum lot size (MODE_MAXLOT), and a lot step (MODE_LOTSTEP). If your EA tries to send a lot of 0.05 on an account where the minimum is 0.1—or a lot of 0.15 on an instrument where the lot step is 0.1—MT4 will reject it immediately .

The fix: Before any OrderSend(), use MarketInfo(Symbol(), MODE_MINLOT), MODE_MAXLOT, and MODE_LOTSTEP to validate and adjust the lot size.

Reason 2: You Skipped Lot Normalization (4-Digit Brokers Are a Trap)

This is where many traders get tripped up. On 4-digit brokers, lot sizes often have 2 decimal places (e.g., 0.10, 0.20, 1.00). But when your EA calculates lot size from account equity (e.g., risking 2%), the result might be 0.12345. Without normalization, sending that value directly to OrderSend() triggers error 131 .

The fix: Use NormalizeDouble() to round the lot size to the allowed number of digits, typically 2 for major pairs on standard accounts: lots = NormalizeDouble(calculated_lots, 2); .

Reason 3: Insufficient Margin for the Calculated Lot Size

Less common but still frequent: the lot size itself passes the minimum/maximum check, but your account free margin can't cover the margin requirement. While MT4 might show "Not enough money" in some cases, certain brokers and conditions report it as error 131 instead .

The fix: Before sending an order, verify if AccountFreeMarginCheck(Symbol(), OP_BUY, lots) returns a value above 0. If it doesn't, reduce the lot size.

Preventing Error 131: Clean Code Practices

Instead of debugging this error repeatedly, build error prevention directly into your EA's logic:

  • Always retrieve fresh market info before each order attempt.
  • Normalize the lot size to the specific instrument's step digits.
  • If the normalized lot falls below the minimum, log it and either skip the trade or scale up to the minimum (if risk allows).
  • For OrderClose(), use the exact lot size from OrderLots()—never assume a value.

When Managing Positions, Error 131 Can Disrupt More Than Just Entries

Here's a practical scenario: You've got multiple open positions, and your strategy requires closing several trades at once based on a signal. Your loop attempts to close each position, but one of them fails due to a stale lot value—and error 131 appears. The loop breaks, and you're left managing the rest manually, potentially missing the exit window.

This is where tools that simplify position management become valuable. Camovia Tray, for instance, lets you view all open positions—symbol, direction, volume, open price, current P&L—directly from your system tray without opening the full MT4 terminal. If a position needs closing, you can tap the card and confirm the close in two steps, bypassing the complexity of EA loops and manual order ticket entry [citation:knowledge].

While it doesn't replace an EA's automated logic, it gives you a reliable fallback for manual intervention when automation fails—without waiting for the terminal to load or navigating multiple menus. Data stays local, and you can check everything with a mouse hover.

The Bottom Line

OrderSend error 131 in MetaTrader 4 is rarely a platform bug—it's almost always a mismatch between what your code sends and what the broker accepts. Check the minimum lot, enforce normalization, and verify margin sufficiency. Once those three steps are part of your EA's routine, error 131 will become a distant memory—and your automated trading can run as intended.

MT4/MT5 Tray Assistant

Silent tracking, one-click close - check quotes and manage positions right from the tray.

Download Camovia Tray

Frequently Asked Questions

How do I download it?

Install from the Microsoft Store - the download page on this site has the link.

How do I report issues or contact you?

Send an email to [email protected].

Where are the privacy policy and user agreement?

The "Privacy" and "EULA" links in the footer of this site, with GDPR/CCPA information included.

What is Camovia Tray?

A tray assistant for MT4/MT5 - silent tracking, one-click close: hover the system tray to check the latest quotes and manage open positions (click an order to close it), hide the MT5/MT4 main window in one click, and keep quote and position data entirely on your computer.

Popular Symbols Trading Hours

Open/close times, weekend hours & live market status: