Equity Curve
Visual account balance chart over time — showing growth, drawdowns, and recovery
What is the Equity Curve?
The equity curve is a line chart showing how your account balance evolved bar-by-bar throughout the backtest. Starting from your initial capital, the line rises with each winning trade and falls with each losing trade. It visually reveals consistency, drawdown periods, and overall growth trajectory.
Built with lightweight-charts, the equity curve supports real timestamps (when market data includes them) or synthetic bar-indexed time. You can overlay up to 50 runs simultaneously for direct comparison.
How the Equity Curve is Computed
The engine extracts equity data directly from the strategy's memory after each run:
- 1
Read inPosition Array
Scans the strategy memory for a variable that contains an inPosition array. This records whether the strategy was in a trade at each bar (0 = flat, 1 = in position).
- 2
Detect Entries and Exits
Transitions 0→1 mark trade entries. Transitions 1→0 mark exits. The entry price is read from the entryPrice array at the entry bar.
- 3
Compute Per-Trade P&L
For each trade: profit = (exitPrice − entryPrice) × quantity − commission − slippage (long) or (entryPrice − exitPrice) × quantity − commission − slippage (short).
- 4
Accumulate Equity
Starting from initialCapital, equity is accumulated trade-by-trade. One equity point is recorded after each closed trade.
- 5
Handle Open Positions
If the strategy is still in a trade at the last bar, a synthetic final point is computed using the last available close price.
- 6
Map to Timestamps
Bar indices are mapped to real timestamps from the market data (t or timestamps array). Falls back to synthetic 60-second intervals if timestamps are unavailable.
Multi-Run Overlay
The equity curve can overlay multiple backtest runs simultaneously for direct visual comparison.
Top N Runs
A dropdown lets you choose how many runs to overlay: 5, 10, 20, or 50. The top N results (by Net P&L) are displayed.
Line Colors
Each run gets a distinct color from a fixed palette: blue, amber, emerald, red, purple, pink, cyan, lime.
Selected Highlight
The currently selected result (from clicking in the Leaderboard or Heatmap) is drawn prominently on top.
Legend
A legend shows which color corresponds to which parameter combination, so you can match lines to results.
Line Color Palette
Reading the Equity Curve
Here is what to look for when interpreting an equity curve:
Steady Upward Slope
Consistent gains with small dips. This is the ideal pattern — indicates a robust strategy with manageable drawdowns.
Jagged Sawtooth Pattern
Big wins followed by big losses. High volatility strategy — might work but is emotionally difficult to trade live.
Deep Drawdown Periods
Long periods of decline. Check the Max Drawdown % stat. If drawdowns are over 30%, reconsider the strategy's risk management.
Flat Then Spike
Long flat periods punctuated by sudden large gains. May indicate the strategy relies on rare events — good for statistical analysis but risky live.
Monotonically Declining
Steady losses throughout the test period. The strategy has no edge on this market/parameter combination. Discard or rethink the approach.
Diverging Lines (Multi-run)
In overlay mode, lines that diverge widely indicate high parameter sensitivity. Prefer parameter sets where the lines stay close together — more robust.
Time Axis
When market data includes timestamps (the t or timestamps array), the X-axis shows real dates and times matching your historical data range.
Without timestamps (e.g. when testing on synthetic data), the engine generates synthetic 60-second intervals starting from Unix epoch 1,600,000,000. The chart still works correctly — axis labels just show relative bar numbers.