Grid bot risk calculator

Platform
Account

From the exchange’s margin tier table for your position size. The position is liquidated when equity falls to MMR × position value.

Orders

The price of the first order. Money is counted in the quote currency: USD for XAUUSD, BTCUSDT or EURUSD.

Size in

Order #k = first order × multiplier to the power (k − 1), #1 being the first order, as in the table: 1 keeps the orders equal, 2 doubles each one (martingale). A $ size is converted to units at the start price.

Step between orders
Step in

1 = equal steps; 1.5 = every gap is 1.5 times the previous one.

Take-profit and stress test

Take-profit is counted from the average price of the open orders. Extra move: how much further than the last order the price goes, in % of the start price; the result shows the deposit that move needs.

Liquidation price—
Room after the last order—
Rebound to take-profit—
Deposit for the stress move—

This is arithmetic of the settings, not a forecast. A martingale or averaging grid with leverage carries risk: with too small a deposit a stop-out is possible.

Every order of the grid

Each row is the moment that order fills

Every order of the grid
# Move from start Price Size Total size Average entry Margin used P/L at this price Equity Margin ratio

Cross margin: margin ratio = maintenance margin ÷ equity × 100 %, where maintenance margin = MMR × size × current price; the exchange liquidates at 100 %. Margin used is the initial margin, size × price ÷ leverage.

Running a grid on gold?The Midas Grid emulator replays any gold day since January 2025 tick by tick with your grid settings. Free, in the browser.

How the stop-out and liquidation price of a grid is calculated

A grid is stopped out at the price where equity falls to the platform’s requirement; between two orders the position does not change, so that price solves a linear equation.

  • p_i = P0 × (1 − s × (1 + k + … + k^(i−1)) ÷ 100)Price of order i of a long grid (order 0 is the first one; a short grid adds the step). s — step in % of the start price P0, k — step scale. With a step in price units: p_i = P0 − s × (1 + k + … + k^(i−1)).
  • q_i = q0 × m^iSize of order i in units (lots × contract size). m — volume multiplier.
  • Q = Σ q_i, A = Σ q_i × p_i, average = A ÷ QTotal size, cost and average entry price of the orders that are open.
  • equity(P) = D + Q × P − AEquity of a long at price P (a short: D + A − Q × P). D — deposit.
  • margin = Σ q_i × p_i ÷ L = A ÷ LMargin on MT4/MT5 is charged at the open price of each order. L — leverage. A new order opens only if the free margin (equity − margin) covers its own margin.
  • P_stop = (A + SO × A ÷ L − D) ÷ QStop-out price of a long on MT4/MT5, from equity = SO × margin. A short: (D + A − SO × A ÷ L) ÷ Q.
  • P_liq = (A − D) ÷ (Q × (1 − MMR))Liquidation price of a long with cross margin, from equity = MMR × Q × P. A short: (D + A) ÷ (Q × (1 + MMR)). A long result of zero or below means no liquidation.
  • P_stop before p_(i+1) → the next orders never openThe equation is solved after every order. If the stop price comes before the next order’s price, the grid ends there; otherwise the next order joins the basket and the price is solved again.

Worked example

A long grid: start price 100, first order 1 unit, volume multiplier 2, step 10 %, step scale 1, 3 orders, leverage 1:10, stop-out 50 % (MT4/MT5), deposit $280, take-profit 5 %. The orders open at 100, 90 and 80 with sizes 1, 2 and 4.

The example grid row by row (MT4/MT5, 1:10, stop-out 50 %, deposit $280)
#PriceSizeTotal sizeAverage entryMargin usedP/L at this priceEquityMargin level
110011100.00$10.00$0.00$280.002 800.0%
2902393.33$28.00−$10.00$270.00964.3%
3804785.71$60.00−$40.00$240.00400.0%
Stop-out at 50.00 (−50.00% from the start)
Average entry(100 + 180 + 320) ÷ 7 = 600 ÷ 7 = 85.71
Margin of the three orders600 ÷ 10 = $60.00
Stop-out price (MT4/MT5)(600 + 0.5 × 600 ÷ 10 − 280) ÷ 7 = 350 ÷ 7 = 50.00
Room after the last order80 − 50.00 = 30.00, 30% of the start price
Take-profit and rebound from 8085.71 × 1.05 = 90.00; (90.00 − 80) ÷ 80 = 12.50%
The same grid on a crypto exchange, MMR 1 %(600 − 280) ÷ (7 × 0.99) = 46.18

The opening check passes at every order: before the third order the equity is $240, the free margin 240 − 28 = $212, and the order needs 4 × 80 ÷ 10 = $32. Open the example in the calculator to see the same rows.

How much deposit a grid bot needs

A grid bot needs enough deposit to keep equity above the stop-out or liquidation level at the lowest price you want to survive, with every order of the grid open.

  • D = A × (1 + SO ÷ L) − Q × TMT4/MT5, long grid; T — the lowest price to survive. A short grid: D = Q × T − A × (1 − SO ÷ L).
  • D = A − Q × T × (1 − MMR)Crypto exchange with cross margin, long grid. A short grid: D = Q × T × (1 + MMR) − A.
  • D ≥ margin of orders 1…i − P/L of the earlier orders at p_iThe deposit must also open every order: before order i the free margin has to cover that order’s margin. The calculator takes the largest of these numbers.

Example (the grid above: A = 600, Q = 7, margin $60, stop-out 50 %, 1:10): surviving a fall to 40 — 40 % of the start price beyond the last order — takes 600 × (1 + 0.5 ÷ 10) − 7 × 40 = 630 − 280 = $350. On a crypto exchange with MMR 1 %: 600 − 7 × 40 × 0.99 = $322.80.

Deposit for the example grid by how far the price goes beyond the last order (80)
Extra move after the last orderLowest priceMT4/MT5, stop-out 50 %Crypto, MMR 1 %
0%80$100.00$100.00
10%70$140.00$114.90
20%60$210.00$184.20
30%50$280.00$253.50
40%40$350.00$322.80
60%20$490.00$461.40
80%0$630.00$600.00

At 0 % the limit is opening the orders, not the stop-out: at 80 the first two orders are $40 down and all three need $60 of margin, so the deposit must be at least $100. The extra move is counted in % of the start price.

Stop-out on MT4/MT5 vs liquidation on a crypto exchange

MT4 and MT5 compare equity with the margin charged at each order’s open price, while a crypto exchange compares it with a maintenance margin that follows the current price.

  • MT4/MT5: equity ≤ SO × Σ q_i × p_i ÷ LStop-out. The margin is fixed when the orders open; leverage divides it.
  • crypto: equity ≤ MMR × Q × PLiquidation with cross margin. The maintenance margin is a share of the position value at the current price P.

So on MT4/MT5 a higher leverage lowers the margin and moves the stop-out further away. With cross margin on a crypto exchange the liquidation price of the same position and balance does not depend on the leverage setting: leverage limits how large a position can be opened, and the balance behind it is what counts. With isolated margin it does depend on leverage, because only the position value ÷ leverage is put aside.

Example: the same grid and deposit ($280; 1, 2 and 4 units at 100, 90 and 80) under five rules.

Where the example grid is closed, by platform rule
Platform and ruleStop priceFrom the startAfter the last order
MT4/MT5, 1:10, stop-out 50%50.00−50.00%30.00
MT4/MT5, 1:10, stop-out 20%47.43−52.57%32.57
MT4/MT5, 1:100, stop-out 50%46.14−53.86%33.86
Crypto, MMR 1%46.18−53.82%33.82
Crypto, MMR 0.5%45.94−54.06%34.06

A lower stop-out level, a higher leverage on MT4/MT5 or a lower MMR all move the stop further away by a few percent. The deposit and the size of the orders move it much more: see the deposit table above.

For gold on a cent account with Midas settings use the martingale grid calculator. For a DCA bot with safety orders in $ use the DCA bot calculator.

Formulas and worked example

With the default settings — a long futures grid from price 100, 10 orders 2% apart, the first worth $50 and each next ×1.5, on $1,000 at 10× leverage with a 0.5% maintenance margin rate — all 10 orders fill by 82.00 (18.00% below the start) and liquidation comes at about 68.34, 31.66% below the start. Enter your own grid to see its stop-out or liquidation price.

Reviewed

Frequently asked questions

How much deposit does a grid bot need?

Enough to keep equity above the stop-out or liquidation level at the lowest price you plan for, with all orders open. For a long grid on MT4/MT5: D = A × (1 + SO ÷ L) − Q × T; on a crypto exchange: D = A − Q × T × (1 − MMR), where A is the cost of all orders, Q their total size and T the lowest price. Example: orders of 1, 2 and 4 units at 100, 90 and 80 cost 600; surviving a fall to 40 at 1:10 and stop-out 50 % takes 630 − 280 = $350.

What is the liquidation price of a grid bot?

It is the price where equity falls to the maintenance margin: for a long grid with cross margin P = (A − D) ÷ (Q × (1 − MMR)), for a short P = (D + A) ÷ (Q × (1 + MMR)). It moves every time a new order fills, so it has to be solved order by order; the calculator above does that and shows whether the liquidation comes before the last order.

How many safety orders can my deposit hold?

As many as fill before the stop-out price and while the free margin still covers the next order. Enter the deposit and a large number of orders: the table shows which orders open, which are refused for lack of margin and where the stop-out row cuts the grid. With a multiplier of 2 every new order is larger than all the previous ones together.

Is a martingale grid safe?

No. A martingale or averaging grid closes small profits while the price comes back, but a long one-way move fills every order, and with leverage it can take the whole deposit at the stop-out or liquidation price. The calculator shows where that price is for your settings; it does not tell how likely such a move is. Use only money you can afford to lose.

Does leverage change the stop-out or liquidation price?

On MT4/MT5 yes: margin = position value ÷ leverage, so a higher leverage lowers the margin and the stop-out comes later (in the example 1:10 gives 50.00 and 1:100 gives 46.14). With cross margin on a crypto exchange the same position and balance have the same liquidation price at any leverage setting; leverage limits how much can be opened.

What is the difference between stop-out and liquidation?

Both close positions when the account can no longer carry them. A stop-out on MT4/MT5 comes when equity ÷ margin falls to the broker’s level (for example 50 %), with the margin fixed at the open prices. A liquidation on a crypto exchange comes when equity falls to the maintenance margin, MMR × position value at the current price.

What does the calculator leave out?

Commissions, swaps and funding, spread, slippage, price gaps, lot rounding and margin tiers (on exchanges the MMR grows with the position size). A broker or an exchange may also close positions partly or in a different order. Treat the result as arithmetic of the settings, not as a guarantee.

About this calculator

How far can the price move before a stop-out or a liquidation? Enter a martingale or averaging grid for any asset — an EA on MT4/MT5 or a futures bot on a crypto exchange — and see the stop-out price, the margin of every order and the deposit a deeper move needs.

Share this scenario

“Copy link with settings” puts the grid into the page address, so whoever opens the link sees the same numbers. Settings left at their defaults are not written, and nothing is sent to a server.

Parameters: mode = crypto | fx, side = long | short, dep deposit, leverage, mmr %, stopout %, price start price, size first order with unit = usd | coin | lot and contract (units in 1 lot), vmult volume multiplier, orders, gap step with gapunit = pct | abs, gapscale step scale, tp take-profit %, extra extra move %.

Example: ?mode=fx&dep=280&price=100&size=1&unit=coin&vmult=2&gap=10&orders=3&tp=5&extra=40 opens the worked example above.

Midas Grid is a grid Expert Advisor for gold on MT5.Its panel shows the distance to stop-out for a live account, the same arithmetic as on this page.