Performance Metrics
After a backtest completes, the engine computes a set of statistics from the closed trades. These metrics appear in the results panel and are used as optimization targets.
Core Metrics
| Metric | Formula | Description |
|---|---|---|
| tradeCount | Count of closed trades | Total trades executed |
| wins | Trades with profit > 0 | Number of winning trades |
| losses | Trades with profit <= 0 | Number of losing trades |
| winRate | wins / tradeCount | Win percentage (0-1) |
| totalProfit | Sum of all trade P&L | Net profit after fees |
| totalFees | Sum of all fees paid | Total commission cost |
| totalReturn | Final equity - initial | Absolute dollar return |
| totalReturnPercent | totalReturn / initial * 100 | Percentage return |
| avgTradeLength | Avg bars held per trade | Average holding period |
Risk Metrics
Max Drawdown
The largest peak-to-trough decline in equity during the backtest:
maxDrawdown = max(peak - trough) for all equity peaks maxDrawdownPercent = maxDrawdown / peak * 100
A lower drawdown indicates better capital preservation. Strategies with 50%+ drawdowns are risky — a 50% loss requires a 100% gain to recover.
Sharpe Ratio
Risk-adjusted return, measuring return per unit of volatility:
sharpeRatio = mean(returns) / stdDev(returns) * sqrt(annualizationFactor)
| Sharpe | Interpretation |
|---|---|
| < 0 | Losing money |
| 0 - 1 | Below average |
| 1 - 2 | Good |
| 2 - 3 | Very good |
| > 3 | Excellent (verify, may be overfit) |
Bidirectional Metrics
When using bidirectional trading mode, additional metrics break down performance by direction:
| Metric | Description |
|---|---|
| longTrades | Number of long trades |
| shortTrades | Number of short trades |
| longWinRate | Win rate for long trades only |
| shortWinRate | Win rate for short trades only |
| longProfit | Total profit from long trades |
| shortProfit | Total profit from short trades |
Optimization Targets
These metrics can be used as optimization objectives:
| Target | Direction | Best For |
|---|---|---|
sharpeRatio | Maximize | Risk-adjusted performance |
totalReturn | Maximize | Raw profitability |
profitFactor | Maximize | Gross profit / gross loss |
maxDrawdown | Minimize | Capital preservation |
winRate | Maximize | Consistency |
Interpreting Results
High win rate, low profit: Many small wins and a few large losses. Add stop losses.
Low win rate, high profit: Few big winners carry the strategy. Common with trend-following — accept many small losses for occasional large moves.
High Sharpe, low trade count: May be overfit to a few lucky trades. Verify with more data or walk-forward analysis.
Negative totalReturn with positive winRate: Losing trades are larger than winners. Adjust risk-reward ratio.
Related
- Commissions & Fees — How fees impact metrics
- Debugging — Diagnosing poor metrics