Margin level in MT5: free margin and stop-out explained

8 min readMetaKit

The account showed $9,400 of equity at 15:02 and $1,800 at 15:41, and nobody touched it. That's what a stop-out looks like from the outside: the broker's server closed the positions for you, biggest loser first, and the only warning was a percentage in the terminal's status bar that most people never read.

Margin level in MT5 is that percentage. It is one division, but the four numbers feeding it get confused constantly, so here they are with the exact formulas and an example you can check by hand.

Balance, equity, margin, free margin

Balance is realised money: deposits, withdrawals, and the profit or loss of every closed trade. It does not move while a position is open.

Equity is what the account is worth right now:

equity = balance + floating P&L (+ credit, if the broker gave you any)

Floating P&L includes accrued swap on open positions, so equity drifts a little overnight even when price doesn't.

Margin (the terminal calls it "Margin", the API calls it used_margin) is the collateral the broker has locked against your open positions. It is not a fee and you don't lose it; it's just unavailable for opening more.

Free margin is what's left:

free_margin = equity - margin

Free margin is the number that decides whether a new order gets accepted. If the new position's margin requirement exceeds free margin, the order is rejected with "not enough money", regardless of how healthy the rest of the account looks.

Margin level is the one to watch

margin_level_% = equity / margin × 100

With no open positions, margin is zero and the level is undefined; the terminal shows nothing there. The moment you open a trade it becomes the single most important risk number on the account, because the broker's automatic actions key off it, not off equity or balance.

Here's a concrete case. A $10,000 USD account, 1:100 leverage, buying 1.00 lot of EURUSD at 1.1000.

One lot of EURUSD is 100,000 EUR of notional, worth $110,000 at that price. Margin at 1:100 is one hundredth of that:

margin       = 100,000 × 1.1000 / 100 = $1,100
equity       = $10,000 (nothing floating yet)
free margin  = 10,000 - 1,100          = $8,900
margin level = 10,000 / 1,100 × 100    = 909%

Now price falls 50 pips to 1.0950. One lot of EURUSD is $10 per pip, so the floating loss is $500:

equity       = 10,000 - 500 = $9,500
free margin  = 9,500 - 1,100 = $8,400
margin level = 9,500 / 1,100 × 100 = 864%

(Strictly, the margin is recomputed as the EUR/USD conversion moves, so it shifts by a few dollars. Ignore that for the arithmetic.)

At 1 lot this account is nowhere near trouble. Change one thing, the lot size, and it changes completely. Eight lots at the same price:

margin       = $8,800
free margin  = $1,200
margin level = 114%
pip value    = $80

Fifteen pips against you and free margin is gone, margin level is 100%. Seventy pips and equity is $4,400, margin level 50%. On a broker with a 50% stop-out, that's the number at which the server starts closing your trades. Seventy pips on EURUSD is an ordinary afternoon.

The stop-out is not a margin call

The two get used interchangeably and they are different events with different consequences.

The margin call level (a common setting is 100%, but it is entirely broker-specific) is a warning. When margin level drops to it, the terminal turns the account line red and you can no longer open new positions, because free margin is at or below zero. Nothing is closed. It's a broker's polite version of the phone call the name comes from.

The stop-out level (50% and 20% are common; some brokers set both levels to 100%) is when the server acts. Margin level touches it and the server force-closes positions at market until the level is back above the threshold. You are not asked. There is no confirmation dialog. It happens on the broker's server, so closing your terminal does not stop it.

Both levels are set per account by the broker and shown in the terminal under the account's properties. They are not in the symbol specification and not something you can change.

The stop-out closes the biggest loser first, one at a time

The order matters, and people assume the wrong thing. The server does not flatten the account. It closes the position with the largest floating loss, recalculates margin level, and stops if the level is now above the stop-out threshold. If it isn't, it closes the next largest loser, and so on.

Two consequences. First, a stop-out usually leaves you with something open, typically your best-performing position, which feels like a consolation prize and is actually just arithmetic. Second, the closes happen at whatever bid or ask exists at that instant. In a fast market with a thin book the fills can be far from the last quote, and a gap through the stop-out level can take equity below zero. Whether the broker then resets you to zero (negative balance protection) is, again, broker-specific. Ask before you need to know.

In the deal history a stop-out close is not a mystery. The exit deal carries reason: "stop_out", which is how you distinguish it from a stop-loss hit (stop_loss) or a manual close (client) after the fact.

Hedged positions change the margin, not the exposure

On a hedging account you can hold buy 1.00 and sell 1.00 EURUSD at the same time. Net exposure is zero: whatever price does, one leg gains exactly what the other loses. What margin does depends on the broker.

Many brokers charge margin on the larger leg only, so the pair above uses $1,100, not $2,200. Others use a separate "hedged margin" rate from the symbol specification, often half the normal rate per lot, occasionally zero. The result is that a fully hedged book can sit with a fixed equity and a fixed margin level for days, while swap quietly accrues on both legs and pushes equity down anyway.

The danger is taking the hedge off. Close one leg and margin jumps to the full rate on the survivor at the same moment its floating P&L starts moving. A margin level that looked frozen at 130% can be at 90% a second later. On a netting account none of this exists: buy 1.00 then sell 1.00 leaves no position and no margin. The netting vs hedging post covers what else changes between the two modes.

Leverage changes margin, not risk

The same 1-lot EURUSD trade at three leverage settings:

LeverageMarginMargin level at openValue of one pip
1:30$3,667273%$10
1:100$1,100909%$10
1:500$2204,545%$10

The last column is the point. Leverage decides how much collateral is locked and therefore how much size the account will let you open. It does not change what a 50-pip move costs you: $500 on one lot at every leverage. High leverage is dangerous only because it lets you open the 8-lot position, not because it makes the 1-lot position riskier.

If you size positions from free margin ("I have $8,900 free, so I can add eight more lots") you are sizing from the broker's collateral rule instead of from your own risk. The position sizing post is the other half of this. Prop firms, incidentally, don't care about your margin level at all; they care about drawdown from the day's starting balance, which the prop-firm drawdown post walks through.

Watching margin level over the API

MetaKit's account object exposes the four inputs directly: balance, equity, used_margin, free_margin, plus leverage and credit. Margin level isn't a field, so compute it, and guard the flat-account case:

import os
import requests
 
BASE = "https://api.metakit.cloud"
HEADERS = {"Authorization": f"Bearer {os.environ['METAKIT_KEY']}"}
ACCOUNT_ID = 2
 
acct = requests.get(f"{BASE}/v1/accounts/{ACCOUNT_ID}", headers=HEADERS).json()
 
if acct["status"] != "connected":
    raise SystemExit(f"account is {acct['status']}; live figures are not populated")
 
equity, used = acct["equity"], acct["used_margin"]
level = equity / used * 100 if used else None  # no positions: undefined
 
print(f"balance       {acct['balance']:>12,.2f}")
print(f"equity        {equity:>12,.2f}")
print(f"used margin   {used:>12,.2f}")
print(f"free margin   {acct['free_margin']:>12,.2f}")
print(f"margin level  {level:>11,.0f}%" if level else "margin level   n/a (flat)")

Polling that in a loop is the wrong tool for the actual job, which is being told before the stop-out rather than after. Equity monitors support margin_level as a metric, evaluated roughly every 20 seconds server-side while the account is connected:

monitor = requests.post(
    f"{BASE}/v1/monitors",
    headers=HEADERS,
    json={
        "account_id": ACCOUNT_ID,
        "name": "Margin level guard",
        "metric": "margin_level",
        "comparator": "below",
        "threshold": 200,
        "rearm_mode": "recovery",
        "channel": "telegram",
        "channel_config": {
            "bot_token": os.environ["TG_BOT_TOKEN"],
            "chat_id": os.environ["TG_CHAT_ID"],
        },
    },
).json()
 
print(monitor["id"], monitor["status"])  # 4 armed

Set the threshold well above the broker's stop-out, not at it. At 200% you have time to close something yourself; at 55% you have a notification about what already happened. recovery re-arms the monitor once the level climbs back past the threshold, so a choppy day produces one alert per breach rather than one per evaluation. Creating a monitor needs a full-scope key (it's a POST); a read-only account gets one monitor, a full account gets three. Details of channels and re-arm modes are in the API reference, and the alerts post covers Slack and Discord setup.

Open the terminal on any account you run, find the margin call and stop-out levels in the account properties, and write them down. It's a two-minute task, and the difference between 50% and 100% is the difference between a bad day and an empty account.