Backtesting Grid Strategies

🟣 İleri Seviye · 2025-03-28

Backtesting Grid Strategies

Backtesting lets you evaluate a grid configuration against historical price data before risking real capital. It answers the question: if I had run this exact grid setup over the past month, what would have happened? While backtesting cannot predict future performance, it helps you identify configurations that are fundamentally flawed before they cost you money.

How to Run a Backtest in Gridera

  1. Open your bot’s detail page and scroll to the Backtest panel.
  2. Enter your grid settings: Grid Low, Grid High, Number of Grids, Total Budget, and Leverage.
  3. Select a time period (1 Day to 3 Months) or set a custom date range.
  4. Click Run Backtest.

The system fetches real historical price data from Pacifica and simulates your exact grid strategy. Results include: Net PnL, ROI, Win Rate, Total Trades, Total Fees, Max Drawdown, and Open Positions.

What Backtesting Simulates

A grid backtest replays historical price data through your grid configuration and tracks:

  • Total trades executed: How many buy-sell round trips completed.
  • Realized profit: The sum of all completed grid trades minus fees.
  • Unrealized PnL: The value of positions still held at the end of the test period.
  • Maximum drawdown: The worst peak-to-trough decline during the period.
  • Grid break events: Whether and when the price exited your range.
  • Capital utilization: What percentage of your capital was actively deployed.

The simulator processes each price candle, checks which grid levels would have been crossed, and executes the corresponding buy and sell orders at the grid prices.

Setting Up a Backtest

To run a meaningful backtest, you need:

Historical price data: OHLCV (Open, High, Low, Close, Volume) candles for your asset. Use 1-minute or 5-minute candles for accurate results. Daily candles miss intraday oscillations and dramatically undercount grid trades.

Grid configuration: The same parameters you would use live: grid low, grid high, number of levels, order size, leverage, fees, and any bias mode settings.

Starting conditions: Initial capital, starting price, and whether you begin with empty or pre-filled grid positions.

Fee model: Include maker/taker fees and, for perpetual futures, funding rate estimates. Backtests that ignore fees produce misleadingly positive results.

Interpreting Results

Focus on these metrics when evaluating backtest results:

Net profit after fees: This is the only number that matters for viability. If the net profit is negative or barely positive after fees, the configuration needs adjustment regardless of how many trades it generated.

Drawdown-to-profit ratio: Divide maximum drawdown by total profit. A ratio below 2 means you risked at most $2 for every $1 earned, which is acceptable. A ratio above 5 suggests the risk is not worth the return.

Trade frequency: More trades generally mean more robust results. A backtest with 200 completed round trips is much more statistically meaningful than one with 10.

Time in drawdown: How long was the strategy underwater? Extended drawdown periods (weeks) indicate the configuration may be poorly suited for the tested market conditions.

Limitations of Backtesting

Backtesting has significant limitations that you must understand:

No slippage modeling: Real markets have slippage, especially during volatile periods. A backtest fills every order at the exact grid price, which does not always happen in practice.

Candle resolution matters: Using hourly or daily candles means you only know the open, high, low, and close, not the actual path the price took. The price might have hit your grid levels in a different order than the backtest assumes.

Survivorship bias: If you backtest 20 configurations and pick the best one, you are fitting to historical data. The best past configuration is not necessarily the best future configuration.

Market impact ignored: In real trading, your orders affect the market. Large grid orders can move the price, especially in thin markets. Backtests assume your orders have zero market impact.

Regime changes: A backtest on sideways market data will show grid trading is profitable. A backtest on trending data will show it is not. Historical conditions do not repeat exactly.

Best Practices

Test multiple periods: Run the same configuration against at least three different time periods, including bullish, bearish, and sideways markets. A good configuration survives all three, even if returns vary.

Use realistic fees: Always include fees in your backtest. A configuration that looks profitable at 0% fees but fails at 0.04% round-trip fees was never truly profitable.

Compare against benchmarks: Compare your grid bot results against simple buy-and-hold for the same period. In strong trends, buy-and-hold often wins. In sideways markets, the grid should outperform.

Stress test with extreme data: Include at least one period with a major crash (30%+ drop in days) in your test data. This reveals how your configuration handles tail events and whether your grid break and stop loss settings would have protected you.

Walk-forward testing: Instead of testing on the entire dataset at once, test on the first half, optimize, then validate on the second half. This reduces overfitting to historical data.

From Backtest to Paper Mode

Backtesting gives you historical validation. The next step before going live is paper mode, which tests your configuration against real-time market data without risking capital. This bridges the gap between historical simulation and live trading by testing execution mechanics, WebSocket feeds, and timing in real conditions.

Summary

  • Backtesting replays historical price data through your grid configuration to estimate profitability, drawdown, and trade frequency.
  • Always include realistic fees, test across multiple market regimes, and compare against buy-and-hold benchmarks.
  • Backtests have inherent limitations including no slippage, candle resolution assumptions, and inability to predict regime changes.

Next Step

Move from historical testing to real-time simulation with Paper Mode Guide.

✨ Was this article helpful?

Ask your questions on Ask on Discord →