Ready to go further
Margin decides if you are still trading when a bad run arrives
Expected value tells you the average. Check the average first, then the margin.
What is included
- What it is, in plain words
- The formula or mechanism, with exact arithmetic
- How it hits grid, martingale and DCA bots
- A check you can run before you switch a bot on
Who it is for
- People who run or plan to run a trading bot
- Anyone reading a backtest or a bot sales page
- Readers who want the numbers, not the pitch
- Not advice, and not a signal service
Key facts
- A margin call is a warning, or an automatic action, from your broker when account equity falls too close to the margin your open trades need.
- Margin level = equity / used margin x 100. Each broker sets its own margin call level and stop out level. Some use 100 percent and 50 percent, others differ, so read your broker's terms.
- At stop out the broker closes positions, usually the biggest losers first, whether or not you want them closed.
- A bot that adds to losing trades uses the most margin exactly when equity is lowest.
- The example numbers on this page are made up to show the mechanics. They are not from any broker or bot.
What a margin call is
When you trade with leverage, the broker holds part of your account as margin against each open position. If trades move against you, your equity falls while the margin stays held. A margin call is the broker's signal that the cushion between the two is getting thin.
Depending on the broker it may be an email, a banner in the platform, or nothing at all before the next step. The next step, the stop out, is automatic. The broker closes positions to free margin, and it does this at the market price available at that moment, which in a fast market can be worse than the price you saw.
The two formulas
Margin level = equity / used margin x 100
Equity is your balance plus or minus the floating profit or loss on open trades. Free margin is equity minus used margin, and new positions need free margin to open.
A worked example with one position
Take a $1,000 account holding one position worth $10,000 at 30:1 leverage. Used margin is $10,000 / 30 = $333.33. With no floating loss the margin level is 1,000 / 333.33 = 300 percent. Now let the position lose money while the account stays otherwise unchanged:
| Floating loss | Equity | Margin level | What happens in this example |
|---|---|---|---|
| $0 | $1,000 | 300% | |
| -$300 | $700 | 210% | |
| -$500 | $500 | 150% | |
| -$667 | $333 | 100% | Margin call level reached |
| -$833 | $167 | 50% | Stop out level reached |
For a currency pair quoted in dollars, a $10,000 position moves about $1 per pip, so a $667 loss is roughly 667 pips. One small position is a long way from a margin call. The danger comes from size and from adding more positions as the first one loses.
Why bots reach it first
A martingale or grid bot opens extra positions as price moves against it, and martingale bots make each one bigger. That is the opposite of what the margin level needs: more margin used at the moment equity is shrinking. Here is a ladder that doubles every step, starting at 0.1 lot (a $10,000 position), on the same $1,000 account at 30:1:
| Step | New lots | Total lots | Margin used | Share of the $1,000 |
|---|---|---|---|---|
| 1 | 0.1 | 0.1 | $333 | 33% |
| 2 | 0.2 | 0.3 | $1,000 | 100% |
| 3 | 0.4 | 0.7 | $2,333 | 233% |
| 4 | 0.8 | 1.5 | $5,000 | 500% |
| 5 | 1.6 | 3.1 | $10,333 | 1,033% |
The second step already needs all of the starting balance as margin, before counting the floating loss that made the bot add it. In practice the broker rejects the order for lack of free margin, and the ladder stops where the account does, with every earlier loss still open.
What a stop out does to a bot
- The recovery logic never gets to run. A bot built to win back losses by waiting is closed out at the low.
- Positions close at whatever price is available. In a gap the fill can be worse than the stop out level suggests, and some account types can end with a negative balance.
- The bot may reopen. If it is still switched on, it can start the same ladder again on what is left.
- The record looks different afterwards. A stop out usually appears as one very large loss in the account history, which a backtest that ignored margin would not have shown.
Checks before you run any bot
- Find your broker's margin call level and stop out level, and write them down.
- Work out the largest total position the bot can open, step by step, and the margin that needs.
- Work out how far price has to move for the bot to reach that point, with the floating loss included.
- Decide your own cap on margin used, test the bot against it, and check what the bot does when an order is rejected.
- Run it on a demo account through a fast move before it touches real money.
Keep Going
Related Tools and Guides
Keep exploring
FAQ
Frequently Asked Questions
Is a margin call the same as a stop out?
No. A margin call is the warning level and a stop out is the level where the broker starts closing positions. Some brokers send no warning and go straight to the stop out. Check which levels your broker uses.
Does a margin call mean I lose everything?
Not necessarily, but it can come close. At stop out the broker closes positions at market prices, so the loss is whatever the account has fallen to by then. On some account types a fast gap can leave a negative balance.
Can a bot avoid margin calls?
It can be written to size positions inside your margin and to stop adding when free margin runs low. That is not certain to work in a fast market, and many martingale and grid bots are written to keep adding.
What is free margin?
Equity minus used margin. It is the room left to open new positions or absorb more loss. When it reaches zero, new orders are rejected.
Will the broker warn me first?
Not always. Some send an email or platform alert at the margin call level, others act at the stop out level only. A bot running unattended may not be able to act on a warning, so its own limits matter more.
Are the numbers on this page real?
Example numbers are made up to show how the maths works, and the page says so. A figure only counts as exact when the page says it was calculated on a stated date. Nothing you enter in a calculator leaves your browser.
Can I use this to decide whether to run a bot?
It can show whether a bot's numbers hold together and how much an account can lose. It cannot say what the market will do, and it is not advice. Use it to ask better questions, then read the terms of your own broker or exchange.
Is this financial advice?
No. It explains how margin works in general. Your broker's terms decide what happens on your account.
Know the Risk Before You Run It
Free calculators and guides, added every week. Leave your details and we will email you when new ones go up.
Trading carries a risk of loss