Test
Backtesting workspace, results, replay, compare, and rolling cross-validation
Before risking real capital, use Test to backtest your algorithm against historical data, review the trade-by-trade results, replay entries and exits, and run rolling cross-validation.
For a hands-on first test, see the Test Walkthrough →
On this page: Running a Backtest · Local Drafts · Fees & Slippage · Results · Replay & Compare · Optimize · Under the Hood
Running a Backtest
Section titled “Running a Backtest”Open Test, select an algorithm, choose your setup, and click Run Backtest. Test uses the same strategy logic you built in Build, so it is the place to check the algorithm before you run it live.
Inputs
Section titled “Inputs”| Parameter | Description |
|---|---|
| Algorithm | Saved algorithm and version to test |
| Start / End | Historical window for the backtest |
| Symbol | Market to test, such as BTC or ETH |
| Exchange | Exchange venue, usually Hyperliquid |
| Initial Capital | Simulated starting capital for this test |
| Leverage | Leverage assumption for the run |
| Trades Limit | Maximum number of trades to simulate |
| Session Calendar Policy | Whether the algorithm pauses around configured windows |
| Assume Position Now | Starts the test as if the strategy is already in trade |
| Close Position on Exit | Closes any open position at the end of the test window |
Local Drafts
Section titled “Local Drafts”The Test workspace lets you make temporary edits without changing the saved algorithm.
Use the side rail to move between:
- Setup — market, dates, capital, leverage, trades limit, and session policy
- Entry — temporary entry condition edits
- Exit — temporary exit condition edits
- Reset — reset and follow-up behavior
Draft edits are useful for quick experiments. When you find an improvement you want to keep, go back to Build and save a new algorithm version.
Fees & Slippage
Section titled “Fees & Slippage”| Cost | Default | Description |
|---|---|---|
| Fees | Exchange-specific (bps) | Deducted from trade value on entry and exit |
| Slippage | Exchange-specific (bps) | Price impact — longs slip up on entry, down on exit; shorts the reverse |
Both are applied to every trade. Position size is calculated after deducting entry fees and slippage.
Results
Section titled “Results”Key Metrics (Check These First)
Section titled “Key Metrics (Check These First)”These five metrics give you the fastest read on whether your strategy is working:
| Metric | What It Tells You | Good Range |
|---|---|---|
winRate | Percentage of winning trades | > 40% (depends on R:R) |
profitFactor | Gross profit / gross loss | > 1.5 (> 2.0 is strong) |
sharpeRatio | Risk-adjusted return (annualized return / volatility) | > 1.0 (> 2.0 is strong) |
maxDrawdownPct | Largest peak-to-trough equity decline | < 20% (lower is better) |
totalPnlUSD | Net profit/loss in USD | Positive, obviously |
Full Metrics Reference
Section titled “Full Metrics Reference”Returns
Section titled “Returns”| Metric | Description |
|---|---|
totalTrades | Total completed trades |
winningTrades / losingTrades | Profitable vs unprofitable trades |
totalPnlUSD | Net profit/loss in USD |
grossProfitUSD / grossLossUSD | Sum of winning / losing trade P&L |
avgPnlUSD | Average P&L per trade |
avgWinUSD / avgLossUSD | Average winning / losing trade |
largestWinUSD / largestLossUSD | Best and worst single trade |
Risk-Adjusted
Section titled “Risk-Adjusted”| Metric | Description |
|---|---|
sharpeRatio | Annualized return / volatility. > 1.0 is good, > 2.0 is strong |
sortinoRatio | Like Sharpe but only penalizes downside volatility — better for asymmetric strategies |
calmarRatio | Annualized return / max drawdown — how well you’re compensated for worst-case pain |
maxDrawdownPct | Largest peak-to-trough equity decline (%) |
maxDrawdownUSD | Largest peak-to-trough equity decline (USD) |
Trade Breakdown
Section titled “Trade Breakdown”| Metric | Description |
|---|---|
longTrades / shortTrades | Count by direction |
longWinRate / shortWinRate | Win rate by direction |
longPnlUSD / shortPnlUSD | P&L by direction |
avgTradeDurationBars / avgTradeDurationSeconds | Average trade length |
avgWinDurationBars / avgLossDurationBars | Duration of winners vs losers |
totalFeesUSD / totalSlippageUSD | Total execution costs |
Indicator Analysis
Section titled “Indicator Analysis”Each indicator gets a usefulness score (0-100) that tells you whether it’s actually contributing to your strategy’s decisions — or just adding noise.
| Field | What It Tells You |
|---|---|
flipCount | How many times the signal changed |
flipRate | Flips per bar |
avgDurationTrueBars / avgDurationFalseBars | Average length of true/false periods |
pctTimeTrue | Percentage of time the signal was true |
triggeringFlipCount | Flips that actually triggered a condition change |
blockingCount | Times this indicator prevented a condition from triggering |
usefulnessScore | Composite score (0-100) |
Entry scoring weights: entropy (20%) + efficiency (35%) + criticality (30%) + bottleneck (15%)
Exit scoring weights: entropy (25%) + selectivity (40%) + signal density (35%)
Near-Miss Analysis
Section titled “Near-Miss Analysis”Shows how close conditions came to triggering without actually firing. This is valuable when your strategy isn’t trading enough — near-misses tell you which thresholds are too tight and by how much.
State Distribution
Section titled “State Distribution”| Field | Description |
|---|---|
pctTimeFlat | Time with no position |
pctTimeLong / pctTimeShort | Time in long/short positions |
avgTimeFlatBars | Average bars between trades |
Exit Reason Breakdown
Section titled “Exit Reason Breakdown”| Reason | Description |
|---|---|
signal | Exit condition triggered |
stopLoss | Fixed SL hit |
stopLossTrailing | Trailing SL hit |
takeProfit | TP level hit |
endOfBacktest | Position open at backtest end |
Equity Curve
Section titled “Equity Curve”Event-driven snapshots of portfolio value — one data point per trade entry, exit, SL, or TP:
| Field | Description |
|---|---|
timestamp | UTC timestamp |
equity | Total portfolio value |
drawdownPct | Current drawdown from peak |
Use plot_backtest to generate an equity curve chart (PNG) with drawdown overlay.
Replay & Compare
Section titled “Replay & Compare”Use replay controls to step through the test and see when signals, entries, exits, stops, and take profits happened on the chart.
You can also keep completed runs around for comparison. This makes it easier to answer practical questions like:
- Did the new entry rule improve win rate?
- Did the stop loss reduce drawdown?
- Did the algorithm improve because it traded better, or only because it traded less?
Optimize: Rolling Cross-Validation
Section titled “Optimize: Rolling Cross-Validation”Switch the Test workspace from Backtest to Optimize when you want to check whether a strategy generalizes across time. Optimize runs rolling cross-validation: each fold trains on one window and tests on the next unseen window.
How It Works
Section titled “How It Works”|── Train ──|── Test ──| |── Train ──|── Test ──| |── Train ──|── Test ──| |── Train ──|── Test ──|The date range is divided into overlapping folds. Each fold trains on one window and evaluates on the next unseen period. Windows step forward by step_days.
Settings
Section titled “Settings”| Setting | Description |
|---|---|
| Algorithm | Saved algorithm and version to validate |
| Symbol | Market to validate |
| Start / End | Full historical range |
| Train Days | Length of each training window |
| Test Days | Length of each out-of-sample test window |
| Step Days | How far the window slides forward between folds |
Example
Section titled “Example”12-month backtest with 90-day train, 30-day test, 30-day step:
- Fold 1: Train Jan-Mar, Test Apr
- Fold 2: Train Feb-Apr, Test May
- Fold 3: Train Mar-May, Test Jun
- ~9 out-of-sample test periods
Results
Section titled “Results”| What You See | What It Means | What to Do |
|---|---|---|
| Consistent Sharpe/win rate across folds | Strategy generalizes well | Consider a small live run |
| Much better train metrics than test | Likely overfit | Reduce parameter space, simplify, or add regularization |
| Later folds performing worse | Losing edge (regime change) | Re-optimize on recent data, or reconsider the strategy entirely |
The Folds tab is the most important view. If the train windows look strong but the test windows are weak, the strategy may be tuned too tightly to history.
Under the Hood: Simulation Pipeline
Section titled “Under the Hood: Simulation Pipeline”You don’t need to understand the pipeline to use backtesting, but knowing what happens helps you interpret edge cases and trust the results.
1. Data Loading
Section titled “1. Data Loading”Validates inputs, loads historical candles, filters to date range, and computes warmup offset (extra bars needed for indicator calculation).
2. Sub-Bar Loading
Section titled “2. Sub-Bar Loading”Loads intra-bar price data for accurate stop loss and take profit detection. Falls back to OHLC interpolation if high-resolution data isn’t available.
3. MipMap Building
Section titled “3. MipMap Building”Aggregates candles into multiple timeframes (1m, 5m, 15m, 1h, 4h, 1d) for efficient multi-resolution indicator computation.
4. Indicator Calculation
Section titled “4. Indicator Calculation”Computes all indicator values across the full date range using the warmup period.
5. Resampling
Section titled “5. Resampling”Converts continuous indicator values into boolean signals based on signal type and threshold. Detects signal crossings — the exact bars where an indicator flips.
6. Event-Driven Simulation
Section titled “6. Event-Driven Simulation”Runs the state machine (CASH → POSITION → TIMEOUT → CASH) over resampled signals. On each bar:
- Checks entry/exit conditions (AND/OR logic across indicator groups)
- Scans for stop loss and take profit hits using sub-bar data
- Executes trades with fee and slippage deductions
- Tracks equity, drawdown, and trade records
What’s Next?
Section titled “What’s Next?”| Want to… | Go to |
|---|---|
| Take your strategy live | Run Features → |
| Tweak your algorithm settings | Build Features → |
| Walk through your first test | Test Walkthrough → |