
Stop-Out Levels and Margin Calls: What Happens When an Expert Advisor Runs Out of Margin
An Expert Advisor that runs out of margin does not ask for more money; it gets closed out. The stop-out, as the process is called, happens automatically on the broker’s server, and for an automated strategy it is the end of the account rather than an inconvenience. Understanding margin levels, margin calls and stop-outs is therefore a prerequisite to letting an EA run unattended. This article explains the mechanics and how to set controls before going live. Choosing the broker is where the stop-out level is set, so it belongs in the same decision as which broker to use for automated trading.
Margin, free margin and margin level explained
Margin is the amount of account funds reserved to hold your open positions. Used margin is the total of those reservations across all open trades; free margin is what remains available for new positions; equity is balance adjusted for the floating profit or loss of open positions. The relationship between them defines margin level, calculated as equity divided by used margin, expressed as a percentage. Margin level is one of several account numbers worth understanding alongside spreads, slippage and execution speed.
Margin level is the number every safety mechanism watches. When equity rises, margin level rises. When floating losses reduce equity, margin level falls. New positions can usually be opened only while enough free margin exists, so the EA’s ability to keep working depends on this one ratio. The illustrative table below walks an example account through the margins of a stop-out step by step. Note also the difference between balance and equity: balance changes only when a trade closes, while equity moves with every floating profit or loss. It is the equity figure that feeds margin level, which is why an account can approach its stop-out levels while the balance figure still looks healthy, and why monitoring the right number matters more than monitoring the familiar one.
Step | Equity | Used margin | Margin level % | Status |
|---|---|---|---|---|
1 | 10,000 | 1,000 | 1,000 | Normal trading |
2 | 8,000 | 1,000 | 800 | Equity falling, margin level dropping |
3 | 2,000 | 1,000 | 200 | Approaching the margin call level |
4 | 1,000 | 1,000 | 100 | Margin call level reached (example) |
5 | 500 | 1,000 | 50 | Stop-out level reached (example) |
6 | 500 | 350 | 143 | Positions closed; margin level recovers above the stop-out |
What a margin call is and what it is not
A margin call is a warning threshold, not a closing event in itself. When margin level falls to the broker-set margin call level, the platform asks for more funds, typically by alerting the trader and flagging the account as short on margin. The label makes it sound harsher than it is: in most setups no position is closed by the margin call itself.
The action that actually closes positions is the stop-out, which sits at a lower level. The two thresholds are set by the broker and stated in the account risk documents, and they differ between brokers and account types. Treat the margin call as the last warning and the stop-out as the mechanism that follows if nothing is done. Because both thresholds vary, read them in the account documents of any broker you shortlist from our vetted broker comparison.
How a stop-out works and which positions close first
When margin level reaches the broker’s stop-out level, the stop-out engine closes open positions automatically, one by one, generally starting with the largest loss, until margin level recovers above the threshold. The order of closure can vary by broker, but the goal is the same: stop the account falling further.
The process runs on the broker’s server and does not depend on your terminal being connected. An offline terminal changes nothing; the server is the judge. The constants the platform exposes for this are documented in the MQL5 account properties reference, which defines the account margin call and stop-out level constants an EA can read to know its distance to the thresholds.
How an EA can walk an account into a stop-out
An EA walks an account into a stop-out the way any strategy does: by adding risk faster than events justify. Averaging strategies that add positions into a losing move increase used margin and open loss at the same time. A grid EA scaling in through a trending market can exhaust free margin, then equity, in a single sustained move. Compounders that increase size as the balance grows carry larger used margin into each day.
The damage is amplified when expectations come from a backtest, because live conditions differ from historical ones. The standing view of this site is that live drawdown should be assumed at 1.5 to 2 times the backtest figure before you size anything. If a backtest suggests the strategy can draw down a third of the account, plan for half, and check the margin arithmetic at that deeper level. For the full reasoning behind that assumption, see our guide to evaluating EA drawdown risks.
Setting margin controls before an EA goes live
Decide before deployment how far the account is allowed to fall, then encode it. Position size should be chosen so that margin level stays clear of the stop-out even at the assumed worst case, which includes the 1.5 to 2 times drawdown cushion above. A maximum drawdown cap — an equity stop the EA itself respects, or a broker-side risk limit where the platform offers one — turns the worst case from an event into a controlled exit.
Choose leverage deliberately rather than accepting the maximum offered, because leverage sets the distance between normal trading and the stop-out. And monitor on the same VPS you rely on for uptime, with the account settings reviewed whenever the strategy’s parameters change. A written margin plan belongs with the rest of your setup notes; our free trader toolkit includes a Broker & VPS Quick Reference for that purpose.
FAQs
Is a margin call a warning or an action?
In most setups a margin call is a warning at a broker-set threshold. The forced action, the closing of positions, is the stop-out at a lower level. The two should not be treated as the same event.
Does the stop-out level differ between brokers?
Yes. Stop-out levels are set by each broker for each account type, so the same margin level that is safe at one account can be terminal at another. The values are stated in the account documentation, and the distance to them should be part of your sizing arithmetic.
Can a stop-out happen while my terminal is offline?
Yes. The stop-out is executed on the broker’s server, which monitors margin level continuously. Your terminal being offline changes nothing about when positions are closed.
How does leverage change the distance to a stop-out?
Higher leverage reserves less margin per position, so the same trade size leaves more margin headroom and the stop-out sits further away in price terms. The trade-off is that higher leverage also allows dangerously larger positions, which move margin level faster. The distance is a choice, not a fixed value.
Trading foreign exchange and CFDs on margin carries a high level of risk and may not be suitable for all investors. This article is for educational purposes only and does not constitute financial advice.

