OKX · Strategy Hands-On
OKX Grid Bot Settings: Range, Grid Count, Funds Per Grid
The manual form for an OKX spot grid asks you to decide three things: the lower and upper price limits, the number of grids, and how much to invest. Each box is easy to fill in on its own. The trouble is that they are tied together. Range and grid count fix the spacing between grids, the spacing decides what is left after fees, and the investment, spread across the grids, decides how many coins each grid trades and how big a position you are left holding if price slides all the way to the lower limit.
What an OKX spot grid asks you to set
Going by the parameter list on OKX's Spot Grid help page, a manually created bot needs:
- Lowest price and highest price: the bot "will stop placing orders" when the market price is lower than the lowest price or higher than the highest price. Only order placement stops. The bot is not terminated, and the coins it has already bought are still there.
- Grid quantity: the number of grids the price range is divided into. OKX's own example is a 100–400 range in arithmetic mode with 3 grids, which gives 100–200, 200–300 and 300–400.
- Arithmetic or geometric: arithmetic keeps the same difference between neighbouring grids, geometric keeps the same ratio.
- Investment currency and amount: you can invest the quote currency (USDT, say), the base currency (BTC, say), or both. Once the bot is created, the initial funds are isolated from your trading account and used for grid trading only.
- Take-profit price, stop-loss price, trailing: optional. When a take-profit or stop-loss price is hit, the bot stops and sells the base asset at market price.
There is no box for an amount per grid. The bot works that out. The Spot grid bot FAQ describes it this way: the amount per grid is calculated first, typically in base currency, using as much of your investment as possible and spreading it equally across all grid levels. So every grid trades the same number of coins, and that number is backed out from your investment and grid count. "Funds per grid" in this article means that coin quantity multiplied by the grid's price.
How range, grid count and funds per grid limit each other
Written as formulas, the dependencies are easy to see. For an arithmetic grid:
| Quantity | Formula | What limits it |
|---|---|---|
| Spacing per grid | (highest price − lowest price) ÷ grid count | A wider range or fewer grids means a larger spacing |
| Gross margin per grid | spacing ÷ that grid's buy price | Same spacing, lower margin the closer you are to the upper limit |
| Net profit per grid | spacing × coins per grid − the buy fee and the sell fee | If the spacing does not cover two fees, more fills mean more loss |
| Maximum capital tied up | coins per grid × sum of all buy-order prices | For a fixed investment, more grids means fewer coins per grid |
Put some numbers in (made up, to show the arithmetic). Range 80,000–100,000, arithmetic. With 10 grids the spacing is (100,000 − 80,000) ÷ 10 = 2,000; the gross margin on the lowest grid is 2,000 ÷ 80,000 = 2.5% and on the highest it is 2,000 ÷ 98,000 ≈ 2.04%. Cut the same range into 100 grids and the spacing drops to 200, with margins of 0.2%–0.25%.
Fees are charged once on the buy and once on the sell. Assume 0.1% per side (your real rate depends on your tier; see the OKX fee schedule), so about 0.2% for the round trip. The 10-grid setup keeps more than 1.8% per grid. The 100-grid setup keeps almost nothing. That is how fees cap the grid count.
The investment pulls the other way. Keep the amount and the range the same and double the grid count: the spacing halves, each grid trades about half as many coins, and the two together leave roughly a quarter of the gross profit per grid. With the range above and an assumed 0.001 BTC per grid at 10 grids, one grid earns 2,000 × 0.001 = 2 USDT. At 20 grids the spacing is 1,000 and each grid trades about 0.0005 BTC, so one grid earns 1,000 × 0.0005 ≈ 0.5 USDT. To try a different range or grid count quickly, use the grid parameter estimator on this site.
Capital tied up at the lower limit: a worked calculation
A grid buys all the way down. To work out the worst case you need two order-placement rules from OKX's pages:
- Buy orders sit at the lowest price and at every spacing step above it, with no buy order at the highest price itself. The Spot Grid example uses a 50,000–100,000 range with 50 grids, and the buy orders run from 50,000 to 99,000, which is exactly 50.
- When you invest with USDT, buy orders priced above the market fill immediately at creation. In the same example the price at activation is 60,100, and "all the buy orders from 61,000 USDT and upwards will be filled immediately", each followed by its own sell order. Of the 50 buy orders, the 39 from 61,000 to 99,000 are already bought the moment the bot starts.
The second rule deserves a second look. The lower the market price sits inside your range, the more grids are bought on day one. A grid does not wait for a fall before it starts buying.
Now the made-up numbers. Range 80,000–100,000, arithmetic, 10 grids, 0.001 BTC per grid, invested in USDT. The buy orders are at 80,000, 82,000, and so on up to 98,000, ten in all.
| What to compute | Formula | Result |
|---|---|---|
| Sum of the 10 buy-order prices | (80,000 + 98,000) × 10 ÷ 2 | 890,000 |
| Capital used if every order fills at its grid price (upper bound) | 0.001 × 890,000 | 890 USDT |
| Coins held when price reaches 80,000 | 0.001 × 10 | 0.01 BTC |
| Value of those coins at 80,000 | 0.01 × 80,000 | 800 USDT |
| Unrealized loss at that point | 890 − 800 | 90 USDT, about 10.1% |
| Average entry price | 890 ÷ 0.01 | 89,000 |
890 USDT is the upper bound. It assumes the market starts near the upper limit and falls one grid at a time, with every buy order filling at its own grid price. If the market is at 91,000 when you create the bot, rule 2 means the four buy orders from 92,000 to 98,000 fill at market straight away, costing 0.001 × 4 × 91,000 = 364 USDT. If the remaining six from 80,000 to 90,000 all fill later, they cost 0.001 × (80,000 + 90,000) × 6 ÷ 2 = 510 USDT. That is 874 USDT in total for the same 0.01 BTC, and an unrealized loss of 74 USDT at 80,000.
Two things fall out of these numbers. In the upper-bound case the average entry price is simply the average of the buy-order prices, whatever the size of the investment. And the percentage loss at the lower limit depends only on the range and the grid count: hold the lower limit fixed, raise the upper limit, and the percentage grows. Below 80,000 the Spot Grid page says the bot stops placing orders, and the 0.01 BTC is still yours. At 70,000 those coins are worth 700 USDT and the loss has widened to 190 USDT. The same page recommends setting a stop-loss price below the lower price.
To redo this with your own settings: list the buy-order prices, add them up, multiply by the coins per grid, then subtract total coins × lowest price. For the coins per grid, read the quantity on any open order in the bot's details.
How to choose the lower and upper price limits
The upper and lower bounds shouldn't be picked off the top of your head; use support and resistance as the reference. Put simply:
- Support: a price level where, historically, price has repeatedly bounced and couldn't fall further — usable as a reference for the lower bound.
- Resistance: a price level where price has repeatedly fallen back and couldn't rise further — usable as a reference for the upper bound.
Finding them isn't complicated either: pull up the coin's candles over the past month or two, see which range price keeps swinging within, and roughly where the upper and lower edges sit. Set the grid's upper bound near resistance and the lower bound near support — meaning "I'm betting price keeps chopping within this validated box."
Two suggestions when you set them. First, leave some margin below the support you see for the lower limit, because support can be pierced briefly and then recovered (a wick), and a little margin keeps one wick from pushing price out of your range. Second, the range does not have to capture the extremes. Set a band you judge price will keep moving within. Every step you lower the bottom limit changes the capital and unrealized-loss figures in the table above, so recalculate them.
Can you use OKX's AI parameters as they are?
Besides the manual form, the creation screen can fill in AI parameters for you. The Spot Grid help page says of them: "These parameters are based on a weekly backtest of this pair."
A weekly backtest tells you about roughly one week of price action. A range fitted to that week reflects that week's swing and nothing more, and once the market moves outside it, the range no longer fits. Treat the suggestion as a first draft: put its range and grid count through the formulas above, see how much capital is tied up and how large the unrealized loss is at its lower limit, then decide whether to push the lower limit down or thin out the grids. Whether to set a stop-loss, and where, is still your call.
Bot stopped, confusing PnL, or a range that should follow price: which article to read
Filling in the form is only the start. The questions that come up once the bot is running each have their own article:
- The grid has stopped placing orders. Is price out of range, or has the bot actually stopped? What happens to your coins differs between the two: OKX grid bot stopped: out of range vs. actually terminated.
- How Total PnL, Grid profits and Unpaired PnL are each calculated, and why grid profit can be positive while total PnL is negative: OKX spot grid Total PnL, Grid profits and Unpaired PnL.
- How Trailing Up and Trailing Down each move the grid, and why trailing down takes extra funds at every level: OKX spot grid trailing up and down.
- If you are thinking of running the grid on futures, read about leverage, liquidation and funding fees first: OKX futures grid vs spot grid.
FAQ
Is a higher grid count always better on an OKX spot grid?
No. In arithmetic mode the spacing per grid is (upper price − lower price) ÷ grid count, so more grids means a smaller spacing, and every completed grid pays a fee on the buy and again on the sell. Take a range of 80,000–100,000: with 10 grids the spacing is 2,000 and the gross margin per grid is about 2.04%–2.5%; with 100 grids the spacing is 200 and the margin is about 0.2%–0.25%, which a round trip at an assumed 0.1% per side (0.2% in total) all but wipes out. Keep the spacing clearly above two fees.
Does an OKX spot grid buy coins the moment it is created?
It does when you invest with USDT. In the example on OKX's Spot Grid help page (range 50,000–100,000, 50 grids, price at activation 60,100) all the buy orders from 61,000 upwards fill immediately and a sell order is placed for each of them, so 39 of the 50 buy orders are already done at creation. The lower the market price sits inside your range, the more grids are bought at the start.
If price falls below the lower limit, does the grid sell automatically?
No. The help page says the bot stops placing orders when the market price is lower than the lowest price. Only the order placement stops; the coins already bought stay in the bot, and the unrealized loss keeps growing if price keeps falling. The bot stops and sells the base asset at market only when a stop-loss price is set and triggered. OKX recommends setting the stop-loss below the lower price.
What data are OKX's AI grid parameters based on?
The Spot Grid help page says the parameters are based on a weekly backtest of the pair. That reflects roughly the last week of price action, so the range may stop fitting once the market leaves it. Before using them, plug the suggested range and grid count into the formulas and see how much capital would be tied up at the lower limit.
If you would rather create the grid from code than from the app, the endpoints and parameters for placing, querying and stopping one are covered in Using the OKX API to create and stop a grid bot.