Running a Backtest
Learn how to create and execute backtests to validate your trading strategies.
Prerequisites
Before running a backtest:
- Active TradeStaq account with Pro tier or higher
- Understanding of the strategy you want to test
- Clear hypothesis about expected performance
Quick Test (AI Builder)
The fastest way to test a strategy is the built-in Quick Test in the AI Strategy Builder.
How It Works
- Open the AI Strategy Builder (Dashboard → Strategies → AI Builder)
- Generate or paste strategy code in the editor
- Click Quick Test in the editor toolbar
- Configure the test:
| Setting | Description |
|---|---|
| Exchange | Select a connected exchange for market data |
| Symbol | Trading pair (e.g., BTC/USDT) |
| Timeframe | Candle timeframe (e.g., 1h, 4h) |
- Results appear in seconds with basic metrics
Quick Test Metrics
| Metric | Description |
|---|---|
| Return | Total profit/loss percentage over 7 days |
| Win Rate | Percentage of winning trades |
| Trades | Total number of completed trades |
| Max Drawdown | Largest peak-to-trough decline |
| Profit Factor | Gross profit divided by gross loss |
Note: Quick Test runs a fixed 7-day window. For longer testing periods, use Full Backtest.
Full Backtest
For comprehensive testing with configurable parameters and saved results.
Step 1: Access Backtesting
- Navigate to Backtests in the sidebar
- Click New Backtest button
- The backtest configuration wizard opens
Step 2: Select Strategy
Choose which strategy to test:
| Option | Description |
|---|---|
| Official Strategies | Pre-built strategies by TradeStaq |
| Community Strategies | Strategies shared by other users |
| Custom Strategies | Your own strategies (all plans) |
| AI-Generated | Strategies created with AI Builder |
When selecting, review the strategy description, required indicators, recommended markets, and parameter options.
Step 3: Configure Market
Trading Pair
Select the symbol to backtest. Available pairs depend on the exchange selected.
Timeframe
Choose the candle timeframe:
| Timeframe | Description | Best For |
|---|---|---|
| 1m | 1 minute candles | Scalping strategies |
| 5m | 5 minute candles | Short-term trading |
| 15m | 15 minute candles | Intraday trading |
| 1h | 1 hour candles | Swing trading |
| 4h | 4 hour candles | Position trading |
| 1d | Daily candles | Long-term strategies |
Note: Shorter timeframes require more computational resources and may take longer to complete.
Multi-Timeframe Configuration
If your strategy uses multi-timeframe analysis (e.g., td.htf()), the backtesting engine auto-detects the required timeframes from your strategy code. No manual configuration needed — the engine fetches data for all referenced timeframes automatically.
Supply/Demand Zones
If your strategy uses supply/demand zone detection, these are also auto-detected from strategy code. The engine pre-computes zone data before running the simulation.
Step 4: Set Date Range
| Tier | Max Period | Max Historical Data |
|---|---|---|
| Pro | Per tier config | Per tier config |
| Trader | Per tier config | Per tier config |
| Whale | Per tier config | Per tier config |
Note: Check the Plans Comparison for exact limits per tier.
Date Selection
| Setting | Description |
|---|---|
| Start Date | Beginning of test period |
| End Date | End of test period |
| Preset Ranges | Last 30/60/90 days, YTD, etc. |
Step 5: Configure Capital
Initial Balance
Set your simulated starting capital:
| Setting | Description | Default |
|---|---|---|
| Initial Balance | Starting USDT amount | $10,000 |
Position Sizing
| Mode | Description |
|---|---|
| full | Use entire available balance per trade |
| fixed | Fixed USDT amount per trade |
| percent | Percentage of current balance per trade |
Leverage (Futures Only)
| Setting | Description |
|---|---|
| Leverage | Position multiplier (1x-125x) |
| Isolated/Cross | Margin mode |
Step 6: Strategy Parameters
Configure strategy-specific settings:
| Type | Example | Description |
|---|---|---|
| Number | RSI Period: 14 | Numeric value |
| Range | SL: 1-5% | Value within range |
| Select | Mode: Aggressive | Dropdown choice |
| Boolean | Use TP: Yes/No | Toggle option |
Step 7: Review & Run
Before running, verify:
- Correct strategy selected
- Appropriate trading pair
- Suitable timeframe
- Reasonable date range
- Proper capital settings
- Optimized parameters
Click Run Backtest to start. Progress indicator shows completion percentage and results are available when complete.
Parameter Optimization (Whale Tier)
The built-in parameter optimization tool performs grid search across parameter ranges to find optimal settings.
| Feature | Description |
|---|---|
| Grid Search | Tests all combinations of parameter values |
| Range Definition | Define min, max, and step for each parameter |
| Results Ranking | Sorted by selected metric (return, Sharpe, etc.) |
| Top N Results | View the best parameter combinations |
Note: Parameter Optimization is available on the Whale tier only.
Backtest Comparison (Whale Tier)
Compare multiple backtest results side-by-side:
| Feature | Description |
|---|---|
| Side-by-Side | Compare 2+ backtests on the same chart |
| Metric Diff | Highlight differences in key metrics |
| Overlay | Equity curves on the same axis |
Monitoring Progress
During Execution
| Indicator | Meaning |
|---|---|
| Progress % | Percentage of candles processed |
| Current Date | Date being simulated |
| Trades So Far | Running trade count |
Execution Time
| Factors | Impact on Duration |
|---|---|
| Date range length | Longer = slower |
| Timeframe | Smaller = slower |
| Strategy complexity | Complex = slower |
| Server load | High = slower |
Common Issues
"Insufficient Historical Data"
Cause: Requested date range exceeds available data
Solution: Reduce date range or upgrade tier
"Strategy Validation Failed"
Cause: Strategy code has errors
Solution: Check strategy configuration
"Backtest Timeout"
Cause: Backtest took too long to complete
Solution: Reduce date range or use larger timeframe
Next Steps
- Interpreting Results - Understand your metrics
- Best Practices - Optimize your testing
- AI Builder Testing - Quick Test from AI Builder