Strategy testing and trading software · Germanycontact@stratcorealpha.com · DE
All trading software errors

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.

Own native MT5 margin estimates:100lots222620,0.01lots22.26; three synthetic free-margin guard cases and zero orders.

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. 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. 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. 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.

Check my EA locally

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 behaviour

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

These public questions explain the error; use your own EA log to check whether the same cause applies.

Trading risk disclosure

Futures and forex trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing one's financial security or lifestyle. Only risk capital should be used for trading, and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results.

Hypothetical performance disclosure

Hypothetical performance results have many inherent limitations. No representation is being made that any account will or is likely to achieve profits or losses similar to those shown. There are frequently sharp differences between hypothetical performance results and the actual results subsequently achieved by any particular trading program. Hypothetical results are generally prepared with the benefit of hindsight, do not involve financial risk, and cannot completely account for the impact of financial risk in actual trading. Market conditions, the ability to withstand losses, and adherence to a trading program can all materially affect actual results.

NinjaTrader trademark disclosure

NinjaTrader® is a registered trademark of NinjaTrader Group, LLC. No NinjaTrader company has any affiliation with the owner, developer, or provider of the products or services described herein, or any interest, ownership or otherwise, in any such product or service, or endorses, recommends or approves any such product or service.

Testimonials, when shown, may not represent the experience of other clients and are not a guarantee of future performance or success. Virtual-currency trading carries additional risks. See the CFTC customer advisories. Read the full financial risk disclaimer.