> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dyxy.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Grid bot

> Place a ladder of buy and sell orders across a price range and profit from every swing inside it.

A grid bot splits a price range into levels and places limit orders at each of them: buy orders below the current price and sell orders above it. Every time the price moves from one level to the next and back, the bot buys low and sells high, and keeps the difference. It does not need to predict direction, only movement.

Grid bots work best in **sideways markets**, where the price swings up and down within a range.

## How the grid works

1. You set a lower and an upper price, and the number of grid levels between them.
2. The bot places buy orders at the levels below the current price and sell orders at the levels above it.
3. When a buy order fills, the bot places a sell order one level higher.
4. When a sell order fills, the bot places a buy order one level lower.
5. Every completed buy-and-sell pair locks in the profit of one grid step.

If the price leaves the range, the bot stops trading until it comes back, unless a stop condition ends it first.

## Parameters

| Parameter | What it does |
| - | - |
| **Lower and upper price** | The range the grid covers |
| **Number of grids** | How many levels the range is split into |
| **Grid type** | **Arithmetic**: the same dollar distance between levels. **Geometric**: the same percentage distance between levels |
| **Investment** | Total funds for the bot. Divided across the grid levels |
| **Mode** (futures only) | **Neutral**, **Long** or **Short**. See below |
| **Leverage** (futures only) | Multiplies order sizes and risk |
| **Trigger price** (optional) | Starts the bot only when the price reaches this level |
| **Take profit / Stop loss** (optional) | Stops the bot at a price, or when total profit or loss reaches a set amount |
| **Close position on stop** | Choose whether the bot sells its holdings, or closes its futures position, when it stops |

## Arithmetic or geometric

| | Arithmetic | Geometric |
| - | - | - |
| Distance between levels | Fixed amount, for example \$50 | Fixed percentage, for example 1% |
| Profit per grid | Higher in percent at the lower end of the range | Equal in percent across the range |
| Best for | Narrow ranges | Wide ranges and volatile assets |

## Futures grid modes

* **Neutral.** Starts with no position. Buys below the price and sells above it, so it builds a long as the price falls and a short as it rises.
* **Long.** Opens a long position at start and sells into strength. Profits from swings and from an upward drift.
* **Short.** Opens a short at start and buys back into weakness. Profits from swings and from a downward drift.

## Example

Spot grid on SOL, range $180 to $220, 20 arithmetic grids, \$2,000 investment.

* Each level is \$2 apart.
* Each level holds about \$100.
* When SOL drops from $200 to $198, the bot buys at $198. When it then climbs back to $200, the bot sells at $200, earning about 1% on that $100, before fees.
* A day of choppy price action across many levels repeats this many times.

## Choosing settings

* **Range.** Set it around the zone where the price has been moving recently. Too narrow and the price leaves it quickly. Too wide and each level holds little capital and trades rarely.
* **Number of grids.** More grids mean more trades with smaller profit each. Make sure the profit per grid stays well above the trading fee for a buy and a sell.
* **Stop loss.** Set one below the range on a spot or long grid, and above the range on a short grid.

> [!WARNING]
>
> In a strong trend, a grid bot keeps buying as the price falls, or keeps selling as it rises, and ends up holding a losing position at the edge of the range. With leverage, this can lead to liquidation.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.