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 fromOrderLots()—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 TrayFrequently 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.
Online Tools
Popular Symbols Trading Hours
Open/close times, weekend hours & live market status:
Related Articles
XAUUSD Trading Hours in UTC: The Misconception That Costs Traders Money
XAUUSD trading hours in UTC explained: session phases, broker variations, and how Camovia Tray keeps gold quotes and positions visible from the system tray.
Strategies Prop Firms Ban: Martingale, Grid and News Trading
Martingale, grid, tick scalping and news straddles get gold accounts flagged at prop firms, and Camovia Tray keeps grid levels and basket risk visible.
COMEX Trading Hours as Per Indian Time: What Indian Traders Need to Know
Track COMEX trading hours as per Indian time and monitor gold, silver, and copper prices during peak evening sessions with Camovia Tray for MT5/MT4.
Best High Win Rate Indicator MT4: A Side-by-Side Look at What Really Moves the Needle
Discover how Camovia Tray complements your high win rate indicator MT4 strategy by letting you check quotes and manage positions from the system tray—keeping your terminal hidden and your data local.
Understanding MT4 Subwindows: A Trader's Guide to Multi-Pane Analysis
Learn what MT4 subwindows are and how multi-pane analysis improves trading. Camovia Tray lets you check quotes and positions without keeping MT4 open.
More Articles
US Oil Trading Hours in India: A Complete Guide for MCX Crude Traders
Track US oil trading hours in India and trade MCX crude with confidence. Camovia Tray keeps live quotes and positions one hover away.
How to Open a Demo Account in MetaTrader 5 (Setup Guide)
Open a MetaTrader 5 demo account in minutes—server choice, balance setup, and the mistakes to avoid—then keep practice trades in view.
How Do Crypto Sniper Bots Work on Solana?
Discover how Solana sniper bots work, from detection to execution, and learn how Camovia Tray helps you discreetly monitor positions and manage risk locally.
MT4 vs. MT5: Which Platform Fits Your Trading Style?
Confused between MT4 and MT5? Learn which platform fits your trading style and how Camovia Tray lets you monitor positions from your system tray.
Slippage in Forex: Why Your Trades Don't Always Fill at the Price You See
Learn how slippage impacts forex trades and how Camovia Tray helps reduce operational friction—check quotes and manage positions directly from your system tray.