Skip to content

Forex

Margin Call and Stop Out: Margin Level and Free Margin in MT5

A margin call and a stop out are two margin-level thresholds that a broker sets on a trading account. Margin level is equity ÷ used margin × 100. At the margin call level the account is flagged as short of margin. At the lower stop-out level the broker's server starts closing positions, and in MetaTrader 5 it normally closes the position with the largest loss first. Neither level is universal.

Leverage, each symbol's margin settings and both levels come from the broker, so read them for the exact account before an alert sends orders to it. Margin sits alongside lots, pips, leverage and costs in the trading mechanics library.

Illustrative cover for margin call and stop out: a margin-level gauge with two broker thresholds marked, with the official PineConnector logo.
Margin level falls as equity falls. The broker's margin call and stop-out levels decide when it matters.

Margin call and stop out at a glance

Scroll horizontally to read every column.

Term What it means in MetaTrader 5 Where to read it
Balance Money on the account, not counting the results of open positions. Toolbox, Trade tab, account line. MQL5: ACCOUNT_BALANCE
Equity Balance + credit − commission ± floating profit or loss − blocked profit. Trade tab. MQL5: ACCOUNT_EQUITY
Margin (used margin) Money required to cover open positions and pending orders. Trade tab. MQL5: ACCOUNT_MARGIN
Free margin Equity − margin: the money available to open new positions. Trade tab. MQL5: ACCOUNT_MARGIN_FREE
Margin level Equity ÷ margin × 100, in percent. Trade tab. MQL5: ACCOUNT_MARGIN_LEVEL
Margin call level The broker's threshold at which the account enters the Margin Call state. MQL5: ACCOUNT_MARGIN_SO_CALL. The broker's account terms
Stop-out level The broker's lower threshold at which the trade server starts forced closing. MQL5: ACCOUNT_MARGIN_SO_SO. The broker's account terms
Level mode Whether both levels are set in percent (margin level) or in money (equity). MQL5: ACCOUNT_MARGIN_SO_MODE

The definitions follow MetaQuotes' MetaTrader 5 Help and the MQL5 account properties reference, as of 25 September 2026.[1][2] The terminal highlights the account state line in red "if the account is in the Margin Call or Stop Out state".[1]

How are margin level and free margin calculated?

Margin level % = equity ÷ used margin × 100

Free margin = equity − used margin

  • Equity: MetaTrader 5 calculates equity as "Balance + Credit - Commission +/- Floating profit/loss - Blocked".[1] Broker credit therefore counts toward equity, and a floating loss lowers equity before any position closes.
  • Used margin: the "money required to cover open positions and pending orders".[1] In the Forex calculation mode, one position's margin is "Volume in lots * Contract size / Leverage" in the margin currency. MT5 then converts it to the deposit currency and multiplies it by any margin rate in the symbol specification.[3]
  • Free margin: "the free amount of money that can be used to open positions". Depending on the broker's trading conditions, the equity behind it may include floating profit, floating loss, both, or neither.[1]
  • Margin level: a percentage, where a higher number means more equity for each unit of margin in use. With no margin in use, the ratio has nothing to divide by. PineConnector's EA reference warns that margin-level display "can be unusual when there are no open positions".[4]

Where the broker sets a level L in percent, the equity at which it applies follows from the same formula:

Equity at level L = L ÷ 100 × used margin

The floating loss that reaches the level is the current equity minus that amount. Where the levels are set in money, MetaQuotes' Strategy Tester help says they are read against the account's equity instead of margin level.[5] MQL5 returns the mode as ACCOUNT_STOPOUT_MODE_PERCENT or ACCOUNT_STOPOUT_MODE_MONEY.[2]

What is the difference between a margin call and a stop out?

The margin call level marks an account state; the stop-out level triggers forced closing. The broker sets both, and the stop-out level normally sits below the margin call level.

  • Margin call: in MetaQuotes' description of these settings, reaching the level means "the account switches to the Margin Call state".[5] In MT5's settings, forced closing is tied to the stop-out level, not to this one. TradingView's strategy documentation describes a real-world margin call as "a demand for the trader to immediately deposit additional funds to cover the loss".[6]
  • Stop out: the MQL5 reference says that when equity is not enough to maintain open positions, "the Stop Out situation, i.e. forced closing occurs".[2] MetaQuotes lists closing upon Stop Out among the operations "processed on the server side", so the broker's trade server closes the positions, not your terminal or an EA.[7]
  • Which position closes first: in normal mode, "Stop Out causes the position having the largest loss to be closed first". Where a broker enables FIFO closing on a hedging account, the server finds the oldest losing position on each symbol, then closes the one with the greatest loss among them.[7]
  • Pending orders and the rest of the account: for a test, MetaQuotes says that at the stop-out level "all orders are canceled and all trading positions are closed".[5] The live help pages consulted do not say how many positions a broker's server closes, or when it stops. Ask the broker.

Regulation can fix a level for some clients. In March 2018, ESMA announced a margin close-out rule for retail clients' CFDs, which include rolling spot forex, "at 50% of minimum required margin" on a per-account basis.[8][9] ESMA's FAQ adds that the rule "does not prescribe which positions must be closed out, or in what order".[9] ESMA's own temporary measure expired on 31 July 2019, after most national regulators adopted permanent measures at least as stringent.[10] Outside that scope, and for professional clients, the broker's terms apply.

Worked example: when does this account reach margin call and stop out?

Illustrative example, not a recommendation. The account is in USD with 1:100 leverage. For this illustration only, the broker sets margin call at 100% and stop out at 50%, both in percent mode. The symbol is USDJPY in the Forex calculation mode, with a 100,000 USD contract and a margin rate of 1. Spread, commission and swap are ignored.

  1. Margin for the position. A buy of 4.00 lots needs 4.00 × 100,000 ÷ 100 = 4,000 USD. In this illustration the margin currency is USD, the base currency, which matches the deposit currency, so no conversion applies. On EURUSD the same formula gives euros: a 1.00-lot buy at 1:100 needs 1,000 EUR, which is 1,250 USD at an ask of 1.2500.[3]
  2. Just after entry. Balance and equity are 10,000 USD, margin 4,000 and free margin 10,000 − 4,000 = 6,000. Margin level is 10,000 ÷ 4,000 × 100 = 250%.
  3. After a 2,000 USD floating loss. Equity is 10,000 − 2,000 = 8,000, free margin 8,000 − 4,000 = 4,000, and margin level 8,000 ÷ 4,000 × 100 = 200%.
  4. Margin call at 100%. The level applies at equity of 100 ÷ 100 × 4,000 = 4,000 USD, which is a floating loss of 10,000 − 4,000 = 6,000. Free margin is then 4,000 − 4,000 = 0.
  5. Stop out at 50%. The level applies at equity of 50 ÷ 100 × 4,000 = 2,000 USD, a floating loss of 10,000 − 2,000 = 8,000. The server starts closing, and with one position that position closes. If it closed at exactly that equity, the balance would be 2,000 USD. A gap or slippage can make the loss larger.
  6. A new signal at the 200% state. An additional buy of 6.00 lots would need 6.00 × 100,000 ÷ 100 = 6,000 USD, more than the 4,000 USD of free margin. MQL5's trade server return code for a request the account cannot fund is 10019, TRADE_RETCODE_NO_MONEY.[11]
  7. A smaller signal at the same state. An additional buy of 1.00 lot needs 1,000 USD, which free margin covers. For a same-direction order, MT5 adds the new margin to the existing one.[3] Margin becomes 5,000, free margin 8,000 − 5,000 = 3,000 and margin level 8,000 ÷ 5,000 × 100 = 160%.

The accepted trade moved both thresholds. Margin call now applies at 5,000 USD of equity instead of 4,000, and stop out at 50 ÷ 100 × 5,000 = 2,500 USD instead of 2,000. The further loss that triggers stop out shrinks from 8,000 − 2,000 = 6,000 USD to 8,000 − 2,500 = 5,500 USD. Five lots also lose more per pip than four, so the price distance shrinks by more than that. The pip value guide converts a loss in money into pips.

Illustrative margin-level ladder for one USD account with 4,000 USD of margin: 250% at entry, 200% after a 2,000 USD floating loss, margin call at 100% (equity 4,000, free margin 0) and stop out at 50% (equity 2,000), where the server closes the largest loss first.
Illustrative broker levels of 100% and 50%, not typical or recommended values. Read your own account's levels and mode.

Why should an automated order check margin first?

An alert can arrive while the account already carries other positions, so whether a new order fits is only known at that moment. MetaQuotes' checklist for Market products states: "Before sending every trade order, it is necessary to check if there are enough funds on the account." Its sample check compares the required margin with free margin before calling OrderSend().[12]

  • OrderCalcMargin() estimates the margin for a planned order "not taking into account current pending orders and open positions".[13]
  • OrderCheck() checks whether there is enough money for a trade operation. Its result structure reports the margin required, the free margin left and the margin level after the operation.[14][15] MetaQuotes adds that a successful check "is not an indication that the requested trade operation is sure to be successfully executed".[14]
  • A pending order is checked again when it triggers. If the free margin is not enough at activation, MT5 cancels the order and moves it to history as "Rejected".[16]

The alert triggers, the webhook delivers its message, PineConnector processes it and the EA sends an order request. The broker checks the request, but acceptance is not a confirmed fill. Inspect the order state, deals and resulting position.[25] An order can reduce or close an existing position, so the alert log alone cannot establish the account result.

Illustrative four-stage path from a TradingView alert to a PineConnector signal, an account margin check comparing required margin with 4,000 USD of free margin, and two broker outcomes: 6.00 lots rejected with return code 10019, 1.00 lot fits that margin check and, if filled on the assumptions shown, leaves margin level at 160%.
Illustrative numbers from the worked example. Passing the margin check is not proof of acceptance: volume, stops, filling and session checks still apply.

Where do you find margin values in MT5, TradingView and PineConnector?

  • MetaTrader 5 terminal: the Trade tab of the Toolbox window shows balance, equity, margin, free margin and margin level for the account.[1] Each symbol's Specification shows its margin Calculation mode and may show initial, maintenance and hedged margin, plus a table of margin rates.[17] The help pages consulted do not name a terminal field for the margin call and stop-out levels. An MQL5 program can read them with AccountInfoDouble(); otherwise ask the broker.[2]
  • TradingView: a Pine strategy simulates margin from its "Long leverage" and "Short leverage" inputs, whose defaults come from the margin_long and margin_short parameters of strategy(). The broker emulator "generates margin call events if a strategy’s available funds fall below the required margin percentage". It then liquidates four times the simulated quantity needed to cover the loss.[6] Those events describe the simulation, not your MT5 account. The guide to why TradingView and MT5 results differ covers the other gaps.
  • PineConnector: the syntax reference says to read balance, equity, free margin and margin level in the receiving terminal or account view. It adds: "An old screenshot does not establish values at arrival."[18] The optional accfilter= parameter passes a threshold to the EA's Account Filter Basis. With the Margin Percentage basis, accfilter=200 compares margin level with 200%. With the Free Margin basis, the number is an amount of free margin in the account currency.[4]

Demo test only. Confirm every account sharing the selected License ID is a demo account before creating the alert. These messages request broker trades or closures. Check the exact symbol and permitted volume, and add your configured secret= if required.[26]

Illustrative message, not a recommended size or threshold. Paste it into the TradingView alert's Message field, with your License ID and the exact broker symbol: LicenseID,buy,USDJPY,vol_lots=1,sl_pips=50,accfilter=200. The 200 means margin level only if the receiving EA's basis is Margin Percentage. PineConnector's reference says a bare threshold "is not enough information on its own to identify the metric". It does not establish the comparison for every basis, including whether a value exactly at the threshold passes.[19][4]

Margin-based sizing is a different tool. vol_pct_bal_margin=5 allocates 5% of balance as margin, which on a 10,000 USD balance is "USD 500 margin allocation; not a USD 500 loss limit".[20] The lot size and lot step guide compares the five volume methods.

For a failed order, PineConnector's error reference covers MT4 error 134, where "the account does not have enough available margin for the request", and says to read the required and available margin in the Experts output.[21] Its MT5 table of messages beside error 4756 lists no margin case.[22] How the MT5 EA logs a 10019 rejection is not documented; test on demo. The MetaTrader error guide lists other common errors.

Common margin call and stop out mistakes

  • Treating stop out as a stop loss. A stop out closes positions at the prices available when the server acts, after equity reaches the level. In a fast move or a weekend gap, equity can fall past the level first. ESMA describes negative balance protection for retail CFD clients as "a backstop for when MCO does not work effectively as a result of a very sudden price movement".[9]
  • Assuming a universal 100% and 50%. Brokers set their own levels and mode, and their terms can add closure rules. IG's help centre, for one, lists closures at 50% of the margin requirement and after 24 hours on margin call. It also says IG is "not under any obligation to keep you informed" of a margin call.[23]
  • Reading free margin as a risk budget. Free margin measures collateral, not what a stop loss will cost. Leverage changes margin, not the loss per pip, as the leverage guide explains. The position sizing methods guide covers sizing from a planned loss.
  • Expecting margin to stay fixed. MT5 converts margin at the current exchange rate, and floating margin rates "may vary depending on the volume or notional value of positions on the account".[3] How opposite positions are margined depends on the accounting system and the broker's hedged margin setting. See netting versus hedging accounts.
  • Checking one strategy at a time. Margin covers all open positions and pending orders on the account, so margin level is an account-wide figure.[1] Every strategy and every signal reaching the same MT5 account draws on the same free margin.
  • Expecting TradingView to notice a stop out. A broker stop out closes positions in MT5 only. PineConnector's converter documentation says broker stops and targets added through it "operate separately", and that "the adapter does not resynchronise their positions".[24] A stop out is another close made on the broker side, so by the same logic the strategy's simulated position can stay open after MT5 has closed it.

Margin levels describe when a broker will act on an account. They say nothing about whether a strategy's size or leverage suits it, and automation only sends the orders you define.

Frequently asked questions

What is margin level in MT5?

Margin level in MetaTrader 5 is the account's equity divided by its used margin, times 100, shown as a percentage on the Trade tab of the Toolbox window. An account with 8,000 USD of equity and 4,000 USD of margin has a 200% margin level. The broker compares margin level with its margin call and stop-out levels when those are set in percent.

What is the stop out level in MT5?

The stop out level in MetaTrader 5 is the broker-set threshold at which the trade server starts closing positions, normally the position with the largest loss first. It is expressed either as a margin-level percentage or as an equity amount in the deposit currency. An MQL5 program reads it with AccountInfoDouble(ACCOUNT_MARGIN_SO_SO), and the mode with ACCOUNT_MARGIN_SO_MODE.

What is free margin?

Free margin is equity minus used margin: the money an account can still use to open positions. MetaTrader 5 shows it on the Trade tab and MQL5 returns it as ACCOUNT_MARGIN_FREE. A new order whose required margin exceeds free margin cannot be funded, and MQL5's trade server return code for that case is 10019, TRADE_RETCODE_NO_MONEY.

What is a margin call in forex?

A margin call in forex is the state an account enters when its margin level or equity falls to the broker's margin call level. MetaTrader 5 highlights the account line in red. In MT5's own settings, forced closing starts at the lower stop-out level, although broker terms can add other closure rules. Notification policies also differ by broker.

What happens to my positions at stop out?

At stop out, the broker's trade server closes positions without a request from the trader. In MetaTrader 5's normal mode the position with the largest loss closes first; with FIFO closing enabled, the oldest losing position on each symbol is considered first. Closing happens at market prices, so a gap can produce a larger loss than the level suggests.

Reviewed 25 September 2026. Facts were checked against the linked sources on that date. Nothing in this article was tested on a trading account and no code was compiled.

Related reading

Sources

  1. MetaQuotes – MetaTrader 5 Help: Executing trades, where to view open positions and account state, accessed 25 September 2026.
  2. MetaQuotes – MQL5 Reference: Account properties, accessed 25 September 2026.
  3. MetaQuotes – MetaTrader 5 Help: Margin calculation, retail forex and futures, accessed 25 September 2026.
  4. PineConnector – EA settings: Account Filter Basis, accessed 25 September 2026.
  5. MetaQuotes – MetaTrader 5 Help: Strategy testing, custom trading account settings, accessed 25 September 2026.
  6. TradingView – Pine Script User Manual: Strategies, margin and leverage, accessed 25 September 2026.
  7. MetaQuotes – MetaTrader 5 Help: Closing positions using the FIFO rule, accessed 25 September 2026.
  8. ESMA – ESMA agrees to prohibit binary options and restrict CFDs to protect retail investors, accessed 25 September 2026.
  9. ESMA – Frequently asked questions: ESMA’s product intervention measures in relation to CFDs and binary options (ESMA71-98-125), accessed 25 September 2026.
  10. ESMA – ESMA ceases renewal of product intervention measures relating to contracts for differences, accessed 25 September 2026.
  11. MetaQuotes – MQL5 Reference: Trade server return codes, accessed 25 September 2026.
  12. MetaQuotes – The checks a trading robot must pass before publication in the Market, accessed 25 September 2026.
  13. MetaQuotes – MQL5 Reference: OrderCalcMargin, accessed 25 September 2026.
  14. MetaQuotes – MQL5 Reference: OrderCheck, accessed 25 September 2026.
  15. MetaQuotes – MQL5 Reference: Request check result structure (MqlTradeCheckResult), accessed 25 September 2026.
  16. MetaQuotes – MetaTrader 5 Help: Basic principles, pending orders, accessed 25 September 2026.
  17. MetaQuotes – MetaTrader 5 Help: Market Watch, viewing symbol specification, accessed 25 September 2026.
  18. PineConnector – Syntax: look up account and EA values, accessed 25 September 2026.
  19. PineConnector – Syntax: accfilter=, accessed 25 September 2026.
  20. PineConnector – Syntax: vol_pct_bal_margin=, accessed 25 September 2026.
  21. PineConnector – EA errors: MT4 134, insufficient margin, accessed 25 September 2026.
  22. PineConnector – EA errors: match the message beside 4756, accessed 25 September 2026.
  23. IG – What is margin call?, accessed 25 September 2026.
  24. PineConnector – Pine Script converter: what the converter supports, accessed 25 September 2026.
  25. MetaQuotes – Basic Principles: order processing, accessed 25 September 2026.
  26. PineConnector – Test your setup: demo account and License ID scope, accessed 25 September 2026.

PineConnector executes the instructions you send it. It does not select trades, manage money, or hold funds. Trading carries risk, and past performance of any strategy does not indicate future results.


Leave a comment

Back To PiCo Blog

Ready when your strategy is

You bring the strategy.We bring the infrastructure.

Connect TradingView to MetaTrader, choose where MT5 runs and put the full PineConnector workflow through its paces from your first month.

Strategy and trading decisions remain yours. The MT5 environment can be ours.

PineConnector Edge

Run the full PineConnector workflow.

$59/mo at launch

Core plan · 1 connection · 1 hosted MT5 environment

Try Core for $7

7 days of Core for $7, then $59/month at the launch price unless you cancel.