Grid
Grid EAs open orders at regular price intervals, building a mesh of buy and sell entries that profits from oscillation. Capital-intensive; requires careful drawdown management to survive trending regimes.
Mechanism
The EA divides a price range into equal steps (e.g. every 20 pips) and places pending buy stops and sell stops at each level. As price oscillates through the grid, filled orders generate running profit. Positions are closed when net floating P&L crosses a configurable threshold. Grid width, step size, and lot scaling determine maximum drawdown.
Suitability
Profitable in consolidating, low-trend markets (ADX < 20). Severely disadvantaged during sustained trends: if price breaks out of the grid range, unrealised losses compound quickly. Best on EUR/CHF, USD/CHF in calm macro environments. Requires $3,000-$10,000 minimum to absorb multi-level open exposure.
Notes
Grid trading abandons the idea of predicting direction. Instead it places a mesh of buy and sell orders at fixed intervals and harvests profit from oscillation. Every time price swings back and forth through the grid, filled orders bank small gains. In a quiet, range-bound market this produces a smooth, almost boring equity curve, which is exactly why grids are seductive. The danger is the trend. When price breaks out of the grid range and keeps going, the EA accumulates losing positions on one side that it never planned to close, and unrealised loss compounds fast.
This page explains how a grid expert advisor actually behaves inside MetaTrader 5. It covers the specific inputs that decide whether it survives, how it fails, and how to build and stress-test one on the EA Builder before real capital is exposed.
How it works: the grid mechanism
A grid EA divides a price range into equal steps and places pending orders at each level. Say EUR/USD trades at 1.1000 and you set a 20-pip step. The EA seeds buy stops at 1.1020, 1.1040, 1.1060 above, and sell stops at 1.0980, 1.0960, 1.0940 below (a two-directional or “hedged” grid). As price rises through 1.1020, that buy fills; if price then falls back, a matching sell closes it for roughly 20 pips minus spread. The grid does not care which way price moves next — it only needs price to keep crossing the same levels.
Three inputs define the whole machine:
- Step size (spacing) — the pip distance between levels. Smaller steps catch more oscillation but stack open positions faster.
- Grid range / level count — how far above and below the seed price the EA will keep placing orders. This is the single most important risk lever, because it caps how many losing positions can accumulate on the wrong side.
- Take-profit logic — most grids close the whole basket when net floating profit crosses a threshold (e.g.
+$50), rather than closing legs individually. The basket target, divided across many small legs, is why grids can show high win rates.
The profit engine is oscillation; the loss engine is trend. When price leaves the grid range in one direction, every order on the far side is now a floating loss that the EA never planned to realise, and it keeps adding to the pile as it seeds new levels. Whether that pile is survivable is entirely a function of the level count and your free margin — which is why grid trading is really a position-sizing problem wearing an entry-strategy costume.
Market conditions: when a grid wins and when it breaks
A grid is a mean-reversion bet. It wins when price is contained — oscillating inside a band without committing to a direction — and it loses when price trends. The cleanest filter is the Average Directional Index (ADX). Readings below 20 signal a rangebound regime where a grid harvests reliably. Readings climbing above 25 warn that a trend is forming and open exposure will build on one side.
| Regime | ADX (14) | What the grid does | Outcome |
|---|---|---|---|
| Tight range | < 15 | Legs fill both sides, baskets close on schedule | Smooth, steady gains |
| Choppy / drifting | 15–25 | Baskets close slower, mild floating loss builds | Marginal; watch exposure |
| Sustained trend | > 25 | One side never closes, losses compound | Drawdown / margin call risk |
This is why pair selection matters more than for a directional strategy. Historically range-bound pairs — EUR/CHF, USD/CHF and other pairs tied to slow-moving macro relationships — spend more time oscillating and less time trending. That is exactly the diet a grid needs. Broad-trending majors and JPY crosses during a rate-hiking cycle are the graveyard of naive grids. A grid running through a central-bank surprise or a risk-off breakout is the textbook failure case. The very “smooth for months” curve that attracts buyers is the setup for the single run that surrenders it.
Parameters and settings in MT5
Inside MetaTrader 5, a grid EA exposes its risk through a handful of inputs on the strategy properties dialog. These are the ones that decide the outcome — set them from the pair’s own volatility, never from round numbers:
| Input | Typical starting point | What it controls |
|---|---|---|
GridStepPips | ≈ 1× ATR(14) on the working timeframe (15–25 on EUR/USD H1) | Distance between levels; tighter = faster exposure build |
MaxLevels | 8–12 per side, hard-capped | The exposure ceiling — your single most important safety input |
LotPerLevel | Fixed (e.g. 0.01) | Position size at each level; keep constant, not scaling |
LotMultiplier | 1.0 (i.e. disabled) | Any value > 1.0 turns the grid into a martingale — a red flag |
BasketTakeProfit | Net +$X across all open legs | Closes the whole basket at target |
BasketStopLoss | Net -$Y — must be set | The circuit breaker that caps the worst case |
The two inputs people skip are the two that keep the account alive. MaxLevels caps how deep the ladder can go before the EA stops adding orders; BasketStopLoss forces the EA to realise the loss and reset instead of holding an open basket into oblivion. A grid with MaxLevels unbounded and no basket stop is not a strategy — it is a delayed margin call.
Two MT5-specific traps are worth flagging. First, pending grid orders consume no margin until they fill. So the strategy tester’s margin figure looks comfortable right up to the moment a trend fills the whole ladder at once — always compute the filled-ladder margin by hand. Second, brokers cap the number of simultaneous pending and open orders per account. A tight grid on a low-cap broker can silently fail to place its deeper levels, quietly changing the strategy you thought you were running.
- Open the EA’s properties in MT5 (
F7on the chart) and setGridStepPipsfrom ATR, not a round number. - Hard-cap
MaxLevelsand set a non-zeroBasketStopLoss— never leave either unbounded. - Confirm
LotMultiplieris1.0unless you have modelled the martingale worst case explicitly. - Run the Strategy Tester over a trending period, then compute the margin the fully-filled ladder would consume at the far edge.
- Only after the filled-ladder margin fits your account with headroom, forward-test on demo for at least a week.
Failure modes: how a grid blows up
Every grid failure traces back to open exposure the account could not carry. The specific paths:
- Trend breakout. Price leaves the range and one side of the grid never closes. Floating loss grows with each new level until the basket stop fires — or, without one, until margin runs out. This is the dominant killer.
- Hidden martingale. Many “grid” EAs quietly scale lots at deeper levels. This flatters the win rate and equity curve in a backtest. But it converts a linear, survivable drawdown into an exponential, account-ending one during a trend.
- Under-capitalisation. The account cannot margin the fully-filled ladder. The EA looks fine for months of partial fills, then a single directional day fills every level at once and triggers a margin call at the worst possible price.
- Curve-fit spacing. The step size was optimised to one historical range. When volatility regime-shifts, the same spacing is either too tight (over-trading) or too wide (missing the oscillation), and the edge evaporates.
- Cost bleed. Tight grids generate a high trade count. Spread and swap on dozens of small legs quietly erode the thin per-leg profit, so a grid that backtests to breakeven often loses money live once real costs land.
How to build and stress-test a grid EA in mt5depot
You do not need to write MQL5 to build a disciplined grid. In the no-code builder you assemble the same machine — a pending-order ladder, a level cap, a basket target and a basket stop — and, crucially, you can stress-test the worst case before risking capital:
- Set spacing from ATR on the exact pair and timeframe you will run, and backtest at least three spacings.
- Hard-cap the level count and confirm the fully-filled ladder fits your free margin with headroom.
- Keep lots fixed; treat any lot multiplier as a martingale that needs its own ruin-probability model.
- Attach a non-zero basket stop-loss so the worst directional run is bounded, not open-ended.
- Backtest over the pair’s worst trending stretch, then forward-test on demo for at least a week.
The value of building it yourself is that you can see the drawdown a purchased grid EA hides. When you run the same grid over a trending period on tick data, the basket that “always recovers” in the marketing either recovers within your margin or it does not. The builder shows you which, before a live account finds out the hard way.
Grid versus a trend strategy
Because a grid profits from oscillation, it is the structural opposite of a trend-following EA — and the two fail in opposite conditions, which is why traders sometimes pair them.
| Grid | Trend-following | |
|---|---|---|
| Best regime | Ranging (ADX < 20) | Trending (ADX > 25) |
| Win rate | High (many small wins) | Low (few large wins) |
| Loss shape | Fat left tail (breakout) | Many small losses (chop) |
| Capital need | High (funds open ladder) | Moderate |
| Worst enemy | A sustained trend | A quiet range |
Neither is “better”; they are tools for different weather. The mistake is deploying a grid as if it were an all-conditions system. It is a range specialist that must be switched off — or protected by a hard basket stop and a trend filter — the moment the market commits to a direction.
Related articles
Frequently asked questions
- What is a grid trading EA?
- A grid trading EA is an expert advisor that places pending buy and sell orders at fixed price intervals — for example every 20 pips — instead of predicting direction. As price oscillates through the grid, opposite orders fill and bank small gains, and the basket is closed when net floating profit reaches a target. It is a mean-reversion tool that thrives in ranging markets and suffers in sustained trends.
- Is grid trading profitable?
- A grid EA can be profitable in ranging, low-trend conditions where price repeatedly crosses the same levels, but its equity curve hides a fat left tail: one directional breakout can accumulate many open losing positions and erase months of gains. Profitability depends far more on drawdown control — grid width, a hard basket stop, and fixed (not martingale) lots — than on the headline win rate.
- What grid spacing should I use in MT5?
- Set the step from the pair's own volatility, not a round number. A common rule is spacing near the 14-period Average True Range on your working timeframe: on EUR/USD H1 that is often 15-25 pips. Wider spacing means fewer, larger fills and a slower-building basket; tighter spacing catches more oscillation but stacks open exposure faster. Backtest at least three spacings on the same tick data before committing.
- How many grid levels can my account fund?
- Divide free margin by the margin per lot at your leverage, then by the lot size per level, to get the maximum simultaneous positions before a margin call. If a grid can open 20 levels of 0.01 lots and the account cannot margin all 20 at the grid's far edge, the EA is under-capitalised. Always size the ladder for the worst case, not the average month.
- Should a grid EA use martingale lot scaling?
- Fixed lots are far safer. Martingale-style scaling — increasing lot size at each deeper level — makes the equity curve look smoother in backtests but converts a grid's manageable drawdown into an account-ending tail during a trend. If you must scale, cap the multiplier and the level count, and model the exact worst-case loss before going live.
- Is grid trading the same as martingale?
- No. A pure grid uses constant lot size at every level and profits from oscillation; martingale increases lot size after losses to force a recovering winner. Many published grid EAs quietly bolt martingale scaling onto the grid, which is where most account blow-ups come from. Read the parameters carefully and treat any lot-multiplier input as a red flag until you have proven the worst case.
Glossary