Request A Free Quote

Grid EA: Average Price, Exposure and the Trend That Ends It

Grid EA on a GBP/USD candle chart: buy orders every 30 pips from 1.3000 to 1.2910, with the average entry price stepping down to 1.2955 as each level fills

A grid EA places orders at fixed distances from each other, for example 20 to 50 pips apart on a currency pair, and lets the market fill them. When price moves against the first order, the next one fills at a better price, and the next after that. The positions are closed together once the combined result reaches a target.

Seen that way, a grid isn’t many small trades. It’s one position built in pieces. Every filled level lowers its average price, which brings the break-even closer, and adds to its size, which makes every further pip against it more expensive. Whether a grid EA survives depends on the balance between those two effects, and on what it does when the market doesn’t come back.

Below are the main kinds of grid EA, the average-price arithmetic behind them, what lot multipliers really do, the risk controls a grid needs, and how to test one so the report shows its risk as well as its profit. At the end is a list of what to put in a specification if you want one built.

Four kinds of grid EA

“Grid” describes how orders are spaced, not what they’re meant to do. The four designs below share the spacing and almost nothing else.

Averaging grid.Adds to a position as price moves against it, so the average entry improves at every level. Profits when price retraces part of the move. Loses when the move keeps going, because the position grows the whole way.
Trend grid.Adds in the direction of the move with stop orders, building a larger position as a trend extends. Profits in long trends. Loses on reversals, because the largest part of the position was added last, at the worst price.
Neutral range grid.Places buy limits below price and sell limits above it, and closes each filled order one step later. Earns a small amount on every swing inside a range. Loses when price leaves the range, since the orders on the wrong side keep filling.
Grid with a lot multiplier.Any of the above with a larger lot at each new level, often doubled. The way back to break-even gets shorter, and the position grows exponentially. This is a martingale, whatever it’s called.

The average price decides the exit

Several positions on one symbol behave like a single position at their volume-weighted average price:

average price = (P₁ × V₁ + P₂ × V₂ + … + Pₙ × Vₙ) ÷ (V₁ + V₂ + … + Vₙ)

where P is each order’s open price and V its volume. Take a GBP/USD buy grid with a 30-pip step and 0.10 lots per level, where a pip is worth $1 per 0.10 lot. The orders fill at 1.3000, 1.2970, 1.2940 and 1.2910. With equal volumes the average is the simple mean, 1.2955.

GBP/USD buy grid with a 30-pip step: buys of 0.10 lots at 1.3000, 1.2970, 1.2940 and 1.2910, the average price stepping from 1.2985 to 1.2955, and the basket closing on the rebound at 1.2965 for plus 40 dollars

At the fourth order the grid holds 0.40 lots and is $180 down. Break-even is 45 pips above the market, and every further pip down now costs $4 instead of the $1 it cost at the first order. On the rebound the basket closes at the average plus 10 pips, 1.2965, for +$40 before costs. That’s the grid’s whole business model: a small, frequent gain, paid for by holding a growing position through a loss.

The formula also explains the exit rule most grid EAs use, a basket target measured from the average price or in money for all positions together. Closing levels one by one is possible, but then the EA has to track which pieces are left and recalculate the average after every close.

Lot multipliers: a shorter way back, a deeper hole

The appeal of a lot multiplier is easy to see in the average price. Larger lots at the lower levels pull the average down faster, so price needs to retrace less before the basket is back to break-even. The cost of that is easy to see too, once you look at the size of the position.

Grid, 30-pip step, first order 0.10 Lots open Floating loss Pips back to break-even Cost of the next pip
Fixed lots, level 4 0.40 −$180 45 $4
Lot × 1.5, level 4 0.82 −$249 30 $8.20
Lot × 2, level 4 1.50 −$330 22 $15
Fixed lots, level 8 0.80 −$840 105 $8
Lot × 1.5, level 8 4.94 −$2,490 50 $49.40
Lot × 2, level 8 25.50 −$7,410 29 $255

At the eighth level the doubling grid needs only 29 pips of retracement, against 105 for the fixed grid. It also holds 25.5 lots, and every pip further down costs $255. Thirty more pips without a bounce add another $7,650.

Floating loss of a GBP/USD buy grid with a 30-pip step and up to 8 levels: fixed 0.10 lots reaches minus 1,560 dollars at 300 pips against, a 1.5 multiplier minus 6,910 dollars, and a 2.0 multiplier passes minus 10,000 dollars about 220 pips in

A multiplier doesn’t make a grid safer. It moves the risk from “often a little” to “rarely a lot”. The doubling grid recovers from most pullbacks faster than the fixed one, and one move of a few hundred pips takes a $10,000 account past zero.

What ends a grid

A grid account rarely fades slowly. It usually runs well for a long time and then meets one move it can’t absorb. Four things set that up.

A move without a retracement.An averaging grid needs price to come back part of the way. A trend that doesn’t pause fills every level and then keeps going, with the full position open.
The stop-out.When equity falls below the broker’s stop-out level, the broker starts closing positions, at the worst point of the move and in its own order. A grid without its own loss limit leaves that decision to the broker.
Gaps and spread spikes.Weekend gaps and news can jump straight past several levels, or fill them at once at a wider spread. The grid’s neat spacing exists only in a calm market.
Swap on many positions.A grid holding eight positions for two weeks pays swap on all of them every night. On the wrong side of the interest rate difference, that alone can eat the basket target.

Risk controls a grid EA needs

None of these remove the risk of a grid. They decide where it stops, and they make sure the EA decides, not the broker.

Hard limitsA maximum number of levels and a maximum total volume. When either is reached, the EA stops adding and the basket is managed as it is.
Basket stopA loss limit for the whole basket, in money or as a share of equity, that closes everything. It’s the one setting that keeps a bad week from becoming the last week.
Volatility-based stepA step set from ATR rather than a fixed number of pips, so the grid spreads out when the market speeds up instead of filling every level in an hour.
Filters for new gridsNo new grid while a trend filter, a news window or the approach of the weekend says the conditions don’t suit it. Filters don’t help a grid that’s already open, so they decide when to start, not when to stop.

Underneath, the EA needs reliable bookkeeping: its own magic number, a basket calculated per symbol, and the ability to rebuild its state from the open positions after a restart. A grid that forgets after a reboot which positions belong to it can open a second grid on top of the first.

Testing a grid honestly

Grid backtests are known for beautiful equity curves, and for a reason. Most of the time a grid wins small amounts, and its losses come rarely and all at once. A test period without that one move shows a strategy that doesn’t exist.

Read the right numbers.Look at maximum equity drawdown and maximum open volume, not only at net profit and balance drawdown. Balance only changes when positions close, so it hides the floating loss the grid carried.
Test long and include trends.Use as much history as the broker provides, and make sure it includes strong one-way periods for each symbol. If the test has no bad month, you haven’t learned what the bad month costs.
Include every cost.Run on real ticks where available, with commission and swaps. Swap is often small per day and large over the life of a basket that waits weeks for its target.
Stress the limits.Rerun the test with a larger step, fewer levels and a tighter basket stop. A grid that only works with one exact set of parameters is fitted to its history.

Broker and prop firm rules

A neutral grid holds buys and sells on the same symbol at once, which needs a hedging account. On a netting account opposite orders cancel each other out. US-regulated forex accounts follow NFA Compliance Rule 2-43(b), which requires first-in, first-out closing and rules out opposite positions in one pair (OANDA). FIFO also affects one-direction grids that close levels individually, since the oldest position has to go first. A grid EA for such an account has to be designed around it from the start.

Many prop firms prohibit grid and martingale strategies outright, or cap risk per trade and total open volume in ways a grid quickly breaks. The rules differ by firm and change often. We look at how firms treat automation in Automated Trading on Prop Firm Accounts.

What to put in a grid EA specification

Whether you’re ordering an EA or reviewing one you’ve bought, these are the questions it has to answer.

Item What to decide
Grid type Averaging, trend, neutral or a combination, and on which symbols.
First entry What starts a grid: a signal, a time, or simply the absence of an open grid.
Step Fixed in pips or based on ATR, and whether it widens at deeper levels.
Lot sizing Fixed, by a multiplier, or by a set table, with the maximum volume of any single order.
Basket exit Target in pips from the average price or in money, and whether levels can close individually.
Hard limits Maximum levels, maximum total volume, basket stop in money or as a share of equity.
Filters Trend, news and weekend conditions that stop a new grid from starting.
Account handling Behaviour on netting and FIFO accounts: refuse to start, or use a compatible mode.
Restart and logging How the EA restores the basket after a restart, and a log of every level, average and exit.

Building one with us

We write grid EAs for MetaTrader 4 and MetaTrader 5 to the client’s own rules, from simple fixed-step grids to multi-symbol baskets with volatility-based steps and equity limits. You talk directly with the developer who writes your code. Before any code is written we go through the step, sizing and exit rules with you, including the limits that decide where the grid stops, and that first consultation is free.

We test the EA with you on real ticks with your account’s costs, then on a demo account at the broker you plan to use. Bugs found after delivery are fixed at no extra cost. Since 2018 our team has completed over 3,000 development projects for traders in more than 120 countries.

Discuss your grid EA →

Prefer to start from your platform? → MetaTrader 4 developers · MetaTrader 5 developers

FAQ

Is a grid EA profitable?

A grid wins often and in small amounts, and loses rarely and in large amounts. Whether it’s profitable over time depends on how its limits handle the rare move it can’t absorb, not on how many baskets it closes in profit.

What is the difference between a grid EA and a martingale?

A grid spaces orders at set distances. A martingale increases the lot after a loss or at each new level. A grid with fixed lots isn’t a martingale, and a grid with a lot multiplier is one.

How do I calculate the break-even of a grid?

Use the volume-weighted average price of all open positions: the sum of each price times its volume, divided by the total volume. Add the costs of the basket, spread, commission and swap, to get the real break-even.

What grid step should I use?

A step tied to the symbol’s volatility, for example a fraction of the daily ATR, adapts better than a fixed number of pips. Whatever the step, the maximum number of levels and the basket stop decide the risk more than the step does.

Can I run a grid EA on a prop firm or a US account?

Many prop firms prohibit grid and martingale strategies, and US accounts follow FIFO rules that rule out neutral grids and complicate closing levels individually. Check the rules before you connect the EA.

Sources referenced in this article:

  1. OANDA, The NFA FIFO rule and its challenges for expert advisors: oanda.com
  2. MetaTrader 5 Help, Trading Principles: netting and hedging position accounting: metatrader5.com

Nordman Algorithms provides software infrastructure for trade automation and does not offer financial advice, trading signals, or managed trading services. This article is for informational and educational purposes only. Prices and results in the examples are illustrations with round numbers, not recorded trades, and exclude spread, commission and swap unless stated. Grid and martingale strategies can lose more than the account balance shown in a backtest suggests. An EA executes the rules it is given and does not adapt to market conditions outside them. Broker, regulator and prop firm rules differ and change over time. Trading leveraged instruments such as Forex, CFDs and futures carries a high level of risk and may not be suitable for all investors. Only risk capital should be used. Full Risk Disclosure