Logo hamster-bot Claude new: MCP Hyperliquid new: Hyperliquid 1 772 of us in the chat
RU EN PT
Loading…

← All strategies

Grid

Grid strategy (grid). The bot places limit buy and sell orders at equal intervals within a set price range. When the price goes down, the bot buys; when it rises by one grid step, the bot sells what it bought. Each pair of trades "bought at a level → sold at the next level up" earns one grid step minus fees.

The grid does not need to guess the market direction: it profits from price swings inside the range, so it works best in a sideways market.

Order type used: Limit (maker only by default). Market - initial buy and grid stop.

The bot chart shows the grid levels: buys, sells, the empty level and the bounds. With more than 60 levels only the bounds are shown.

⚠️ In a strong trend the grid accumulates a position against the move (a long grid in a decline) or exits the position too early (a long grid in a rally). Protection against a prolonged trend - stop_out_percent.

How the range is set - range_type

ValueGrid boundsWhen it fits
fixedSet manually: lower_price and upper_priceYou know the corridor the price moves in
percent± range_percent % from the start priceThe universal default
atr± atr_mult × ATR from the start priceThe grid width adapts to the current volatility

Direction - direction

ValueHoldsHow it works
longLongBuys below the price, sells above. The classic spot grid: accumulates the coin on the way down and sells it on the way up
shortShortMirrored: sells above the price, buys back below. Builds a short as the price rises
neutralLong or shortNo position at the start price. Builds a long below it and a short above it. Futures only

On spot only the long direction is available.

Level spacing - spacing

Trailing - trailing

A regular long grid sells everything in a strong rally and stops above the range with no position. With trailing the grid follows the price: when the price moves one step above the upper bound, the bot rebuilds the grid around the new price. A short grid with trailing follows the price down the same way. Works only with range_type percent and atr and does not apply to neutral.

Grid stop - stop_out_percent and restart_after_stop

If the price moves beyond the lower or upper bound by more than stop_out_percent %, the bot cancels all grid orders and closes the position at market.

Size and risk

The size of one cell equals the regular strategy lot from the basic section: for long and neutral - lot_long or balance_percentage_long, for short - lot_short or balance_percentage_short. The bot calculates the size at the start price and keeps it until the next grid rebuild.

Maximum position = cell size × number of cells. Example: balance 1,000 USDT, balance_percentage_long: 4, grid_count: 20 - one cell is about 40 USDT, a fully filled grid is about 800 USDT, i.e. 80% of the balance. Keep this in mind when choosing the percentage and leverage.

Initial buy - initial_market. If the start price is in the middle of the range, a long grid has empty levels above the price and nothing to sell there. With initial_market: true the bot buys at market on start as many cells as there are levels above the price (in the example above - about 10 cells, ~400 USDT at once). For short the bot likewise sells the cells below the price, for neutral it closes the existing position. With initial_market: false the bot buys nothing on start and counts the existing position as filled cells. Without a position a long grid will only buy on dips and will not profit from a rise.

Fees: minimum step

Each cell is two trades, a buy and a sell. The cell profit is roughly the grid step minus two fees. If the step is smaller than two fees, every trade loses money, and the more actively the grid trades, the more it loses. Example: ±10% and 20 cells with geometric spacing give a step of about 1%; with a 0.02% maker fee, 0.04% goes to fees and a cell earns ~0.96%. A ±2% range with the same 20 cells gives a step of only 0.2%, and fees already eat a fifth of the profit.

To pay the maker fee, keep post_only: true. An order that would fill immediately at market is rejected by the exchange, and the bot places it again on the next minute.

Parameters

The grid block in the bot settings, basic.strategy: grid

Example block for a ±8% long grid with 20 cells:

"grid": {
  "range_type": "percent",
  "range_percent": 8,
  "grid_count": 20,
  "spacing": "geometric",
  "direction": "long",
  "initial_market": true,
  "orders_per_side": 10,
  "post_only": true,
  "trailing": false,
  "stop_out_percent": 0,
  "restart_after_stop": false
}

Important to know


Backtest the strategy on historical data in the tester and run it in hamster-bot.