Your EA Has Money in the Account. MT5 Says Not Enough (10019).
Imagine this entirely hypothetical scene: an Expert Advisor spots a setup, checks its rules and sends a buy request. The account balance is positive. The chart looks fine. Then the trade server replies with the digital equivalent of a bouncer folding his arms:
10019 — not enough money.
The trader looks at the balance. “Excuse me? There is money right there.”
There is. But balance is not the same as available margin, and that difference can turn an apparently sensible EA entry into a rejected request.
What 10019 actually tells you
In MetaTrader 5, trade-server return code 10019 is TRADE_RETCODE_NO_MONEY. It means the server does not have sufficient funds or margin available to complete that particular request under the current trading conditions.
It is not proof that the account balance is zero. It is not automatically evidence of an EA bug. And it is definitely not a polite invitation to double your deposit.
Start with the exact return code in the Experts or Journal log. Error 10016 concerns invalid stops; 10030 concerns an invalid filling type. They are different problems. Diagnose the code you actually received.
Four numbers, one uncomfortable conversation
Here is the distinction that matters:
- Balance: settled account funds after closed transactions and applicable account adjustments.
- Equity: current account value, reflecting floating profit or loss and applicable adjustments.
- Margin: collateral allocated to support positions and, where applicable, orders.
- Free margin: the portion of equity not already committed as margin.
Consider a made-up example, in account currency:
| Figure | Illustrative amount |
|---|---|
| Balance | 500 |
| Equity | 420 |
| Used margin | 340 |
| Free margin | 80 |
| Estimated margin for proposed entry | 120 |
The account still displays a balance of 500. But an additional request needing approximately 120 of margin is not supported by just 80 of free margin.
That example is arithmetic, not a broker quotation. Real margin checks depend on the account, symbol, direction, volume, existing exposure, applicable rates and server rules. A pre-trade estimate may also change before execution.
The practical lesson: an EA should size against actual account conditions, not simply admire the balance number.
Why the same EA works on one account and fails on another
First suspect: volume. A requested 0.10 lot is not a universal amount of risk. Gold contract sizes and margin rules can vary by broker and symbol. Even a familiar label such as XAUUSD does not tell you the entire contract specification.
Second suspect: existing exposure. One position may fit. The next position may not. Basket systems and strategies with several simultaneous entries need to consider the next trade's margin, not only the first one's.
Third suspect: floating loss. A position can reduce equity before it is closed. Balance may stay unchanged while free margin shrinks.
Fourth suspect: changing conditions. Margin rates, symbol settings, market prices and the account's available resources can change. A calculation from yesterday is not a lifetime permission slip.
For developers, this is why hard-coding a convenient margin assumption into an EA can be more entertaining than intended.
The developer's checklist: investigate before retrying
1. Record the failed request. Log the server return code, symbol, order type, requested volume, time and relevant account state. Make sure the logged error belongs to the actual failed operation.
2. Read the live account figures. Compare balance, equity, margin and free margin, along with current positions. In MQL5, account properties such as ACCOUNT_EQUITY, ACCOUNT_MARGIN and ACCOUNT_MARGIN_FREE can help capture that state.
3. Inspect the symbol specification. Confirm the broker's actual contract size, volume limits, volume step, margin rates and calculation mode. Do not assume two brokers' gold symbols are identical.
4. Check the proposed trade. MQL5 provides OrderCalcMargin() to estimate margin for a specified operation and OrderCheck() to check a prepared trade request and return margin/account projections. They are useful diagnostics, but neither guarantees that the server will ultimately execute the order. In particular, OrderCalcMargin() calculates margin for the specified operation without accounting for current open positions and pending orders, so it is not a complete portfolio margin verdict.
5. Check the sizing and basket logic. If an EA can add positions, does it re-evaluate capacity for each addition? Does it enforce a maximum aggregate exposure? What happens when an entry is rejected?
6. Handle failure safely. Log the reason, avoid uncontrolled every-tick retry loops, and pause or back off new entries as appropriate. Repeatedly asking the server for an unaffordable trade does not make it cheaper.
7. Reproduce on demo. Use comparable symbol and account settings where possible. A demo test is useful evidence, not proof that live execution will match perfectly.
A useful distinction: insufficient margin is not a margin call
These terms are often mixed up.
Error 10019 concerns a specific trade request that cannot be completed because the necessary funds are insufficient.
A margin call or stop-out concerns account-level margin conditions and the broker's risk-management thresholds. The concepts are related, but they are not interchangeable. An account can reject an additional entry without having reached stop-out.
Similarly, reducing lot size may lower the margin needed, but it is not a guaranteed fix. The broker's minimum volume, existing exposure and current margin rules still apply.
Should you just raise leverage?
Changing leverage or adding funds without understanding the rejected request can hide the sizing problem rather than solve it. More buying power does not make an oversized strategy safer.
A better question is: If this trade were accepted, would the resulting exposure still fit the strategy's risk limits?
Sometimes the correct outcome is to place a smaller trade after proper testing. Sometimes it is to change the EA's entry logic. And sometimes the best trade is the one the EA does not open.
The takeaway
When MT5 returns 10019, resist the urge to argue with the balance display. Look at free margin, current exposure, requested volume, symbol specifications and the actual server response.
The EA may have found a trade. That does not mean the account has room for it.
A good trading robot needs more than an entry signal. It needs to know when the answer is “not today.”


