Grid trading is one of the most reliable strategies for ranging crypto markets. A self-replenishing grid bot places buy orders below price and sell orders above it, automatically re-placing each order after it fills — capturing profit from every oscillation indefinitely.
When a buy order fills, the bot immediately places a new sell order at a higher grid level. When that sell fills, it re-places the buy. The cycle repeats until you stop the bot — capturing profit on every round trip with no manual intervention.
def calculate_grid(price, range_pct, num_levels):
half = num_levels // 2
spacing = (range_pct / 100) / half
buys = [round(price * (1 - i * spacing), 4) for i in range(1, half + 1)]
sells = [round(price * (1 + i * spacing), 4) for i in range(1, half + 1)]
return buys, sells
buys, sells = calculate_grid(75000, range_pct=1.0, num_levels=10)
print(f"Buy levels: {buys}")
print(f"Sell levels: {sells}")
grid_state = {}
def initialise_grid(symbol, price, range_pct=1.0, num_levels=10, order_size_usdt=100):
buys, sells = calculate_grid(price, range_pct, num_levels)
for i, lvl in enumerate(buys):
size = round(order_size_usdt / lvl, 4)
result = place_order(symbol, "BUY", size, order_type="LIMIT", price=lvl)
grid_state[f"B{i+1}"] = {"order_id": result["orderID"], "price": lvl}
for i, lvl in enumerate(sells):
size = round(order_size_usdt / lvl, 4)
result = place_order(symbol, "SELL", size, order_type="LIMIT", price=lvl)
grid_state[f"S{i+1}"] = {"order_id": result["orderID"], "price": lvl}
print(f"Grid initialised: {len(grid_state)} orders")
def check_and_replenish(symbol, current_price, order_size_usdt=100):
for level_id, info in list(grid_state.items()):
side = "BUY" if level_id.startswith("B") else "SELL"
price = info["price"]
filled = (side == "BUY" and current_price <= price) or (side == "SELL" and current_price >= price)
if filled:
size = round(order_size_usdt / price, 4)
result = place_order(symbol, side, size, order_type="LIMIT", price=price)
grid_state[level_id] = {"order_id": result["orderID"], "price": price}
print(f"Replenished {level_id}: {side} at {price}")
BTC at $75,000 — use 0.5% to 2% range, 10 to 20 levels. XRP at $1.33 — use 5% or more range, otherwise levels are too close together. Stop and reset the grid when price breaks more than 5% outside your range and does not return within 30 minutes.
Download the complete self-replenishing grid bot from the LMEX.AI Strategy Builder — configure your symbol, levels, range and order size, then run it directly.
Q: How much capital do I need to start a grid trading bot on LMEX?
You can start grid trading on LMEX with as little as $100, though $500-1000 is recommended for better grid spacing and risk management. The key is to size your grid appropriately so that individual orders represent only 1-3% of your total capital.
Q: What happens if the price breaks out of my grid trading range permanently?
If price breaks above your grid, you'll be left with profits but no position to benefit from further upside. If it breaks below, you'll accumulate more of the asset at lower prices, which can be profitable if price eventually recovers to your grid range.
Q: How do I calculate optimal grid spacing for cryptocurrency trading bots?
Optimal grid spacing typically ranges from 0.5% to 2% depending on the asset's volatility. Calculate the average daily trading range over 30 days, then set grid levels at 1-3% intervals within that range to capture normal price oscillations while avoiding overtrading.
Q: Can grid trading bots work during high volatility crypto market conditions?
Grid bots can be profitable during high volatility as they capture more price swings, but they require wider grid spacing and careful risk management. Consider pausing the bot during extreme market events or news-driven price movements that could break your grid range permanently.