Trading BotsGrid Bot

Grid Bot

1. What Is a Grid Bot

A Grid Bot is an automated trading strategy that places a ladder of buy and sell limit orders across a defined price range. The bot profits from natural price oscillations — buying at lower grid levels and selling at higher ones — without requiring you to predict market direction. Every order executes directly on GXCore with sub-microsecond matching. The Rust engine handles order placement, fill tracking, cycle accounting, and optional trailing logic with zero reliance on external services.

Grid bots perform best when the market moves sideways or oscillates within a band, but GX Exchange also provides strategy presets and a Trailing Up mode that extend grid bots into trending conditions.


2. How It Works

A grid bot divides a price range into equally spaced (or percentage-spaced) horizontal lines called grid levels. At each level the bot maintains a resting limit order.

Upper Bound ──────────── SELL 5     $70,000
                         SELL 4     $68,000
                         SELL 3     $66,000
  Current Price ~~~~~~>  --------   $65,200
                         BUY  2     $64,000
                         BUY  1     $62,000
Lower Bound  ──────────── BUY  0     $60,000

Order lifecycle for one grid cell:

  1. You define an upper bound and a lower bound for the price range.
  2. The bot divides that range into N grid levels (you choose the count).
  3. At every level below the current market price, the bot places a buy limit order.
  4. At every level above the current market price, the bot places a sell limit order.
  5. When a buy order fills, the bot immediately places a corresponding sell order one grid level above it.
  6. When a sell order fills, the bot immediately places a corresponding buy order one grid level below it.
  7. Each completed buy-sell pair is one cycle and locks in grid profit equal to the spacing between those two levels (minus fees).

The bot continues cycling for as long as the price stays within the grid range (or the grid trails the price — see Section 6).


3. Grid Types: Arithmetic vs Geometric

GX Exchange supports two grid spacing modes. The choice affects how your capital is distributed and which market conditions the bot handles best.

Arithmetic Grid

Grid levels are separated by a fixed price difference. If your range is $60,000 to $70,000 with 10 levels, every level is exactly $1,000 apart.

Formula: step = (upper_bound - lower_bound) / grid_count

Geometric Grid

Grid levels are separated by a fixed percentage. Each level is the same percentage above the previous one. This means levels are closer together at lower prices and farther apart at higher prices.

Formula: ratio = (upper_bound / lower_bound) ^ (1 / grid_count)

Comparison Table

AttributeArithmeticGeometric
Spacing methodFixed dollar amountFixed percentage
Level distributionUniform across rangeDenser at lower prices, wider at higher prices
Profit per cycleSame dollar amount at every levelSame percentage return at every level
Best forNarrow ranges, stablecoins, low-volatility pairsWide ranges, volatile assets, large-cap pairs
Capital efficiencyHigher when price stays near the middleHigher when price swings across the full range
Recommended whenRange width is less than 20% of current priceRange width exceeds 20% of current price

Rule of thumb: If you are unsure, use Geometric for BTC and ETH pairs and Arithmetic for stablecoin or low-volatility pairs.


4. Strategies

GX Exchange provides five named strategy presets. Each preset configures the bot direction, grid density, and range boundaries to match a specific market outlook.

StrategyMarket OutlookHow It WorksWhen to Use
RisingMild to moderate uptrendPlaces a long-biased grid with more buy levels below current price. Grid range is shifted slightly above the current price center.You expect the asset to trend upward but with pullbacks along the way.
StableSideways / range-boundBalanced grid centered on the current price. Equal buy and sell levels on each side.The asset is consolidating between clear support and resistance. Maximizes cycle count.
ReversalExpected trend changeConfigures the grid to capture a move back toward the mean after a strong directional move. Range is set around the expected reversal zone.The asset has been oversold or overbought and you anticipate a correction.
To the MoonStrong uptrendAggressive long grid with Trailing Up enabled. Wide range tilted above market price. Fewer, wider-spaced levels to ride momentum.You are very bullish and want the grid to follow price upward without capping gains.
FallingMild to moderate downtrendShort-biased grid with more sell levels above current price. Range shifted below the current price center.You expect gradual decline with bounces and want to accumulate at lower levels.

You can select a strategy preset during bot creation or configure all parameters manually.


5. Main Settings

ParameterTypeDescription
pairStringTrading pair (e.g., BTC-USDT). Any spot pair available on GX Exchange.
directionEnumLong (buy low, sell high), Short (sell high, buy low), or Neutral (both directions).
upper_boundDecimalTop of the grid price range. Sell orders will not be placed above this price.
lower_boundDecimalBottom of the grid price range. Buy orders will not be placed below this price.
grid_countIntegerNumber of grid levels. Minimum 3, maximum 200. More levels means smaller profit per cycle but more frequent fills.
grid_modeEnumArithmetic (fixed dollar spacing) or Geometric (fixed percentage spacing).
total_investmentDecimalTotal capital allocated to the bot, denominated in the quote currency (e.g., USDT).
trailing_upBooleanEnable Trailing Up mode. When price breaks above the upper bound, the entire grid shifts upward. See Section 6.
stop_lossDecimalOptional. If market price drops to this level, the bot cancels all orders, closes positions, and stops.
take_profitDecimalOptional. If market price reaches this level, the bot cancels all orders, closes positions, and stops.
strategyEnumOptional preset: Rising, Stable, Reversal, ToTheMoon, or Falling. Overrides direction and range defaults.

Capital requirements: The engine validates that your total investment can fund all grid levels above the pair’s minimum order size. If the per-level allocation is too small, the engine rejects the configuration and suggests either reducing grid count or increasing investment.


6. Trailing Up Explained

Standard grid bots stop generating profit once the price exits the defined range. Trailing Up solves this for bullish breakouts.

How Trailing Up Works

  1. The bot operates normally within the original grid range.
  2. When the market price breaks above the upper bound, the engine detects the breakout.
  3. The bot shifts the entire grid upward: the lowest grid levels are canceled and new levels are placed above the old upper bound.
  4. The new upper and lower bounds are recalculated so that the grid re-centers around the new price area.
  5. This process repeats each time the price breaks above the new upper bound.

Key Behavior

  • The grid always shifts upward, never downward. This is a bullish-only trailing mechanism.
  • The number of grid levels stays the same — the bot repositions them, not adds or removes.
  • Spacing (arithmetic or geometric) is preserved when the grid shifts.
  • If the price reverses after a trail, the bot resumes normal cycling within the new range.

When to Enable Trailing Up

  • You are bullish but do not want to guess the exact top.
  • You are running the “To the Moon” strategy.
  • The asset has a history of stair-step rallies with consolidation between moves.

When NOT to Enable Trailing Up

  • You expect a range-bound market (the grid will trail into empty space on a false breakout).
  • You are running a short or reversal strategy.

7. Profit Calculation

Grid bot profit has two components:

Grid Profit (realized): The sum of all completed buy-sell cycles. Each cycle earns the price difference between the buy level and the sell level, minus trading fees on both sides.

Unrealized P&L: The mark-to-market value of positions the bot currently holds that have not yet completed a cycle.

Arithmetic: profit_per_cycle = grid_step - (buy_fee + sell_fee) where grid_step = (upper - lower) / grid_count

Geometric: profit_per_cycle = buy_price * (ratio - 1) - (buy_fee + sell_fee) where ratio = (upper / lower) ^ (1 / grid_count)

Example

  • Pair: BTC-USDT
  • Range: $60,000 to $70,000
  • Grid count: 10 (arithmetic)
  • Grid step: $1,000
  • Fee rate: 0.1% maker per side
  • Capital per level: $1,000

Each buy at $64,000 and sell at $65,000 yields $1,000 gross minus approximately $1.29 in fees ($64 x 0.001 + $65 x 0.001 on a $1,000 notional). If the price oscillates across all 10 levels once, total grid profit is approximately $9,987.

Total profit increases with: more grid levels (more cycles), higher volatility (more oscillations), longer runtime, and lower fees.


8. When to Use a Grid Bot

Ideal Conditions

  • The asset is trading in a well-defined range with visible support and resistance.
  • Volatility is moderate — enough to trigger fills but not so extreme that it blows through the range in one candle.
  • You have a medium- to long-term time horizon (days to weeks).
  • You do not want to actively monitor charts and place manual orders.

Less Ideal Conditions

  • Strong one-directional trend with no pullbacks (price exits the grid range quickly).
  • Extremely low volatility (price sits between two levels and nothing fills).
  • Pairs with very wide bid-ask spreads or low liquidity.

Grid Bot vs Manual Trading

AspectGrid BotManual Trading
Execution speedSub-microsecond on GXCoreLimited by human reaction time
Emotional disciplineNo emotion, follows rulesSubject to FOMO and panic
CoverageActive 24/7Limited to screen time
AdaptabilityFixed rules (unless trailing)Can react to news and context
Setup effortOne-time configurationContinuous attention required

9. Example Configuration

Scenario: BTC has been ranging between $62,000 and $68,000 for two weeks. You want to capture oscillations within this range.

SettingValue
PairBTC-USDT
StrategyStable
DirectionNeutral
Lower Bound$61,000
Upper Bound$69,000
Grid Count16
Grid ModeArithmetic
Total Investment$8,000
Trailing UpOff
Stop Loss$58,000
Take Profit$72,000

What happens:

  • Grid step: ($69,000 - $61,000) / 16 = $500 per level.
  • Capital per level: $8,000 / 16 = $500.
  • The bot places 16 resting limit orders across the range.
  • Every time BTC moves $500, one order fills and the opposite order is placed.
  • If BTC drops to $58,000, the bot stops and closes all positions to limit losses.
  • If BTC rallies to $72,000, the bot stops and realizes all gains.

10. Frequently Asked Questions

How much capital do I need to start a grid bot? The minimum depends on the pair’s minimum order size multiplied by your grid count. For most USDT pairs, $100 to $500 is sufficient for a basic grid. The engine will reject configurations where per-level capital falls below the minimum order size.

What fees does the grid bot pay? The bot places limit orders, so all fills are charged the maker fee rate. Fees are deducted from each fill automatically. Your net grid profit is always shown after fees in the bot dashboard.

Can I modify a running grid bot? You can stop and restart a bot with new parameters. Modifying an active grid in-place is not supported because changing bounds or levels would require canceling and replacing all resting orders atomically.

What happens if price exits the grid range? If price rises above the upper bound (and Trailing Up is off), all sell orders will have filled. The bot holds quote currency and waits. If price drops below the lower bound, all buy orders will have filled. The bot holds base currency with unrealized loss. In both cases, the bot resumes cycling if price returns to the range.

How do I choose between arithmetic and geometric? Use arithmetic for narrow ranges (less than 20% of asset price) and stablecoin pairs. Use geometric for wide ranges and volatile assets. Geometric ensures equal percentage returns at every level, which is more natural for assets that move in percentage terms.

Should I enable Trailing Up? Enable it only if you have a bullish bias. Trailing Up is designed for breakout scenarios. In a range-bound market, a false breakout will shift your grid into a zone where price may not return, leaving orders unfilled.

How many grid levels should I use? More levels means more frequent but smaller profits. Fewer levels means less frequent but larger profits. A good starting point is 10 to 20 levels for most pairs. Ensure that the profit per cycle comfortably exceeds twice your fee cost, otherwise fees will eat into returns.

Can I run multiple grid bots on the same pair? Yes. Each bot operates independently with its own capital allocation. Some traders run overlapping grids with different ranges to cover multiple scenarios.

What is the difference between grid profit and total profit? Grid profit counts only completed buy-sell cycles (realized). Total profit also includes unrealized P&L from currently held positions. A bot can show positive grid profit but negative total profit if the price has moved against its holdings.

How long should I run a grid bot? Grid bots are designed for medium- to long-term operation. The longer the bot runs in a favorable range, the more cycles it completes. Most profitable grid bots run for one to four weeks or longer.