Backtesting Grid Strategies
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 te ajuda a identify configurations that are fundamentally flawed before they cost you money.
How to Run a Backtest in Gridera
- Open seu bot’s detail page and scroll to the Backtest panel.
- Enter your grid settings: Grid Baixa, Grid Alta, Number of Grids, Total Budget, and Leverage.
- Select a time period (1 Day to 3 Months) or set a custom date range.
- 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.
- UnPnL realizado: 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 quando o preco exited your range.
- Capital utilization: What percentage of seu capital was actively deployed.
The simulator processes each price candle, checks which nivel de grids would have been crossed, and executes the corresponding compra e venda orders at o grid prices.
Setting Up a Backtest
To run a meaningful backtest, voce precisa:
Historical price data: OHLCV (Open, Alta, Baixa, 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, tamanho da ordem, leverage, fees, and any bias mode settings.
Starting conditions: Initial capital, starting price, and se you begin with empty or pre-filled grid positions.
Fee model: Include maker/taker fees and, for futuros perpetuos, taxa de financiamento 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 profe negative or barely positive after fees, a configuracao needs adjustment independentemente de how many trades it generated.
Drawdown-to-profit ratio: Divide drawdown maximo by total profit. A ratio below 2 means you risked at most $2 for every $1 earned, que e acceptable. A ratio above 5 suggests o risco 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 a estrategia underwater? Extended drawdown periods (weeks) indicate a configuracao may be poorly suited for the tested condicoes de mercado.
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 o preco took. O preco might have hit your nivel de grids in a different order than the backtest assumes.
Survivorship bias: Se voce backtest 20 configurations and pick the best one, voce esta fitting to dados historicos. The best past configuration is not necessarily the best future configuration.
Market impact ignored: In real trading, sua ordems affect o mercado. Large grid orders can move o preco, especially in thin markets. Backtests assume sua ordems 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 e not. Historical conditions do not repeat exactly.
Melhores Praticas
Test multiple periods: Run o mesmo 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: Sempre 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 o mesmo period. In strong trends, buy-and-hold often wins. In sideways markets, o 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 sua configuracao handles tail events and se 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 o primeiro half, optimize, then validate on the second half. Isso reduz overfitting to dados historicos.
From Backtest to Paper Mode
Backtesting gives you historical validation. The next step before going live is paper mode, which tests sua configuracao against em tempo real market data sem risking capital. This bridges the gap between historical simulation and live trading by testing execution mechanics, WebSocket feeds, and timing in real conditions.
Resumo
- Backtesting replays historical price data through your grid configuration to estimate profitability, drawdown, and trade frequency.
- Sempre 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.
Proximo Passo
Move from historical testing to em tempo real simulation with Paper Mode Guide.
✨ Este artigo foi util?
Faca suas perguntas no Discord →