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

  1. Open the AI Strategy Builder (Dashboard → Strategies → AI Builder)
  2. Generate or paste strategy code in the editor
  3. Click Quick Test in the editor toolbar
  4. Configure the test:
SettingDescription
ExchangeSelect a connected exchange for market data
SymbolTrading pair (e.g., BTC/USDT)
TimeframeCandle timeframe (e.g., 1h, 4h)
  1. Results appear in seconds with basic metrics

Quick Test Metrics

MetricDescription
ReturnTotal profit/loss percentage over 7 days
Win RatePercentage of winning trades
TradesTotal number of completed trades
Max DrawdownLargest peak-to-trough decline
Profit FactorGross 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

  1. Navigate to Backtests in the sidebar
  2. Click New Backtest button
  3. The backtest configuration wizard opens

Step 2: Select Strategy

Choose which strategy to test:

OptionDescription
Official StrategiesPre-built strategies by TradeStaq
Community StrategiesStrategies shared by other users
Custom StrategiesYour own strategies (all plans)
AI-GeneratedStrategies 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:

TimeframeDescriptionBest For
1m1 minute candlesScalping strategies
5m5 minute candlesShort-term trading
15m15 minute candlesIntraday trading
1h1 hour candlesSwing trading
4h4 hour candlesPosition trading
1dDaily candlesLong-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

TierMax PeriodMax Historical Data
ProPer tier configPer tier config
TraderPer tier configPer tier config
WhalePer tier configPer tier config

Note: Check the Plans Comparison for exact limits per tier.

Date Selection

SettingDescription
Start DateBeginning of test period
End DateEnd of test period
Preset RangesLast 30/60/90 days, YTD, etc.

Step 5: Configure Capital

Initial Balance

Set your simulated starting capital:

SettingDescriptionDefault
Initial BalanceStarting USDT amount$10,000

Position Sizing

ModeDescription
fullUse entire available balance per trade
fixedFixed USDT amount per trade
percentPercentage of current balance per trade

Leverage (Futures Only)

SettingDescription
LeveragePosition multiplier (1x-125x)
Isolated/CrossMargin mode

Step 6: Strategy Parameters

Configure strategy-specific settings:

TypeExampleDescription
NumberRSI Period: 14Numeric value
RangeSL: 1-5%Value within range
SelectMode: AggressiveDropdown choice
BooleanUse TP: Yes/NoToggle 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.

FeatureDescription
Grid SearchTests all combinations of parameter values
Range DefinitionDefine min, max, and step for each parameter
Results RankingSorted by selected metric (return, Sharpe, etc.)
Top N ResultsView 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:

FeatureDescription
Side-by-SideCompare 2+ backtests on the same chart
Metric DiffHighlight differences in key metrics
OverlayEquity curves on the same axis

Monitoring Progress

During Execution

IndicatorMeaning
Progress %Percentage of candles processed
Current DateDate being simulated
Trades So FarRunning trade count

Execution Time

FactorsImpact on Duration
Date range lengthLonger = slower
TimeframeSmaller = slower
Strategy complexityComplex = slower
Server loadHigh = 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