MT5 · code and request checks
MT5 error 10019: check margin for the actual lot size
Your 100-lot request can fail a margin guard even when its volume is legal. My native MT5 calculation blocked it against supplied free margin.

Arnold Holm · 2026-10-14
What the error means
A trader divided account balance by tick value and obtained a trade size of 100000. The request then failed with 10019, and he asked how lot size should be calculated in MQL5. That example mixes two different questions: how much a price movement could lose, and how much margin the position needs. A lot amount can fit the symbol minimum and step while still needing more margin than the account has available. I compiled and ran a small read-only script in HolaPrime MT5 on EURUSD H1. At its restored Ask 1.11310, OrderCalcMargin estimated 222620 account-currency units for 100 lots and 22.26 for 0.01 lots. I supplied a synthetic free-margin amount of 111321.13 to compare the two requests. The large request was blocked; the minimum request was allowed. A third case checked equality with the estimated minimum-lot margin. I keep the risk amount and the margin estimate separate, then check the complete request before sending.
Three code paths to check
1. Balance is being used as the spending limit
Balance leaves out the account state that matters to the next request. Open positions and current losses can reduce the remaining margin. Log the free margin when the request is checked, rather than reuse a balance value saved earlier. My test supplied free-margin inputs deliberately; it did not pretend that the comparison was a live account state. For your own account, record the current value from AccountInfoDouble and keep the account currency beside it. A screenshot of the balance alone does not explain why one more position was rejected.
2. The risk calculation produces a legal but unaffordable volume
First determine the cash loss you are willing to accept at the intended stop. Then read the symbol rules and normalize the requested lot amount. After that, estimate the margin for this exact symbol, side, price and volume. These checks answer different questions. Using every available unit of margin as a risk budget can leave almost no room for price movement. Increasing the account borrowing limit or depositing money is not a correction to a mistaken lot calculation. I would inspect the actual request before changing either.
3. A standalone estimate is being mistaken for the complete check
OrderCalcMargin is an estimate under the current account and symbol conditions. MetaQuotes says it calculates as if there were no existing positions or pending orders. A hedge or a netting account can therefore need a more complete request check. Read OrderCheck and its result fields for the actual proposed trade, then still handle the result of the eventual send. A positive estimate is not a promised execution. Price, margin requirements or account state can change between checking the request and submitting it.
The read-only margin comparison
The native run used EURUSD minimum0.01 and maximum100 lots. It calculated both amounts at the same cached Ask. The synthetic free-margin value was halfway between the two estimates, so the large request clearly failed the comparison and the small request passed. I also checked the exact equality case. This makes the less-than-or-equal choice visible instead of leaving it buried in the code. Equality passed this arithmetic guard, but that is not a recommendation to use every unit of available margin. A later request check and your risk buffer remain separate decisions. The source contains no OrderSend call.
double required=0;
bool calculated=OrderCalcMargin(ORDER_TYPE_BUY, symbol, lots, ask, required);
bool enough=calculated && required <= freeMargin;This run used native OrderCalcMargin with synthetic free-margin inputs and a restored quote. It reproduced no real10019 rejection and sent zero orders. Values are in the account currency.
How you know it is fixed
Requested margin above free margin is blocked
The100-lot estimate222620 exceeded the supplied111321.13 and closed the guard. Keep the requested lots beside the estimate so a unit mistake cannot disappear behind a generic no-money message.
A smaller legal amount is checked separately
The0.01-lot estimate22.26 passed against the same supplied free margin. Equality also passed. Do not assume that an amount passing this guard fits your stop-loss risk or a challenge loss limit.
Your five-minute Journal check
Find one rejected request in your Journal. Compare its actual lots and estimated margin with free margin at that request time, not just the account balance. Capture the complete check result and the later send result separately. They describe different stages.
Your own source
Find the next line to check
Start with the free EA-Check. Your code stays in your browser. It highlights patterns with line numbers; it does not prove the broker accepts an order.
Want one small change shown on your own case?
SOLVED-FIRST: one small fix or change to your own case, shown first as screenshots or a short screen video. 15 USD fixed (or the higher platform minimum), first five paid orders only during 4–17 October 2026. The file follows within 24 hours after funding. Close on Upwork first; marketplace cases stay on their marketplace.
Outside that sprint: R49: one authorised, reproducible MT4/MT5 defect, with three agreed cases. 49 USD fixed. Delivery within 48 hours after source review and funding. The exact case is agreed before funded work.
Send the expected and actual behaviourRelated checks
Common questions
Should I lower the lot amount until the request passes?
Check the stop-loss cash risk and the symbol minimum first. A smaller amount may solve a margin issue, but changing volume without those checks can also change the trade you intended to take.
Does this screenshot show a broker rejecting100 lots?
It shows a native margin calculation and synthetic free-margin comparisons. There was no submitted order and no real10019 rejection. The Journal and source preserve that distinction.
Sources and limits
- Trader question: calculating lot size after10019
- Official MQL5 standalone margin estimate
- Official MQL5 complete request check
- Own native MT5 margin estimates and three guard cases
These public questions explain the error; use your own EA log to check whether the same cause applies.