Grid trading bot: how it harvests a range (and when it breaks)

A grid bot is the most popular automated strategy in crypto, and for a good reason: it makes money from volatility without predicting direction. It lays a ladder of buy and sell orders across a price range and mechanically buys each dip, sells each pop. This guide breaks down exactly how a grid works, the profit-per-grid math, the one market condition that destroys it, and how to set the parameters that matter.

On this page
  1. How a grid works
  2. Profit-per-grid math
  3. Key parameters
  4. When it wins & breaks
  5. Setup sketch
  6. Test it
  7. FAQ

How a grid bot works

You pick a price range and a number of grid lines. The bot places limit buys below the current price and limit sells above it, evenly spaced. Every time price drops to a buy rung it accumulates; every time it rises to a sell rung it takes profit and re-arms the buy below. No forecast required — it monetizes oscillation itself.

sell sell mid buy buy
Buy rungs (green) below, sell rungs (red) above. Each completed buy→sell cycle banks a small profit.

The profit-per-grid math

Each grid level captures the spacing between rungs, minus fees on both sides. If your range is 5% wide split into 10 grids, each rung is ~0.5% apart. After a 0.1% round-trip fee, each completed cycle nets ~0.3%. The edge is small but repeats every time price crosses a rung — volatility is literally the fuel.

Grid profit = (rung spacing − round-trip fees) × number of completed cycles. More oscillation, more cycles, more profit — until price escapes the range.

The parameters that decide everything

ParameterEffect
Range (upper/lower)Where the grid operates; a breakout past it strands the bot
Grid countMore rungs = smaller, more frequent profits + more fees
Capital per gridPosition size at each rung; controls total exposure
Grid typeArithmetic (equal $) vs geometric (equal %) spacing

When it wins, when it breaks

The grid trap

A grid's worst enemy is a trend. Set a stop below your range, or use a wide range you're comfortable accumulating across, so a breakdown doesn't leave you holding a falling knife.

Setup sketch

python · grid.pylow, high, n = 90, 110, 10
step = (high - low) / n
levels = [low + i*step for i in range(n+1)]
for lv in levels:
    if lv < price: ex.create_limit_buy_order(sym, qty, lv)
    if lv > price: ex.create_limit_sell_order(sym, qty, lv)

Test the grid before you fund it

Select the Grid (range) strategy on our backtester and compare a sideways market against a trending one — you'll feel exactly why grids thrive in chop and bleed in trends.

Not financial advice. This content is educational. Automated and algorithmic trading carries a real risk of financial loss. Never trade money you cannot afford to lose. Review the SEC investor.gov and CFTC resources before trading.

Frequently asked questions

Are grid trading bots profitable?

They can be in sideways, volatile markets where price oscillates within a range — that's their ideal habitat. They lose in strong trends, when price escapes the grid. Match the grid to a ranging market and set a stop, and the math works.

What is the best market for a grid bot?

Range-bound, choppy, high-volatility markets. Crypto pairs that trade sideways for weeks are classic grid territory. Avoid running a tight grid into a strong trend, where it sells winners early or accumulates a crash.

How many grid levels should I use?

More levels mean smaller, more frequent profits but more fees; fewer levels mean larger, rarer ones. A common starting point is 8–20 levels across a range you expect price to oscillate within. Backtest before committing.

Can a grid bot lose money?

Yes. If price breaks out of the range, the bot either sells too early in an uptrend (missing gains) or keeps buying into a crash (holding losses). Always pair a grid with a stop or a range you're comfortable accumulating across.

MB

Mustafa Bilgic

Algorithmic trading practitioner · Founder, AITradingBot.us

Mustafa builds and backtests automated trading systems and writes about them without the hype. Every tool on this site is free and runs entirely in your browser.