Walk-Forward AnalysisStitched Equity Curve

Stitched Equity Curve

The Equity tab (bottom chart area) shows a continuous equity curve built by stitching together the out-of-sample equity points from every fold in sequence. This is the single most important WFA output.

What is Stitching?

Each fold produces an out-of-sample equity series — the equity curve that results from applying the fold's best parameters to its test window. Stitching appends these series end-to-end (adjusting bar offsets) to create a single continuous path.

The result is a realistic picture of what your account balance would have looked like if you had been running the strategy live — with parameters re-optimised at the start of each fold window.

// Simplified stitching logic
stitchedEquity = []
for each fold:
  append fold.oosEquity (bar indices already offset to global bars)
→ single sorted array of { bar, equity } points

How Equity Points Are Extracted

After the OOS backtest runs for a fold, the equity extractor reads the strategy's memory to build discrete equity events:

1
Find Position Data
The extractor scans the backtest memory for the position-tracking node (contains inPosition, entryPrice, values arrays). If no such node is found the fold returns an empty equity series.
2
Read Trade Inputs
Reads initialCapital, quantity, commission, slippage, positionType (long or short) as scalars from the position node memory.
3
Walk the inPosition Array
Iterates bar-by-bar through the inPosition array. A 0→1 transition marks trade entry; a 1→0 transition marks exit.
4
Compute Trade P&L
For long: (exitPrice - entryPrice) × qty − commission − slippage. For short: (entryPrice - exitPrice) × qty − commission − slippage.
5
Emit Equity Point
At each exit bar, a \{ bar: globalBarOffset + i, equity \} point is appended to the fold's oosEquity array.

Chart Features

The equity curve is rendered using lightweight-charts (TradingView's open-source charting library). It supports all standard chart interactions.

Stitched OOS Equity Line
Single line series showing the cumulative out-of-sample equity across all folds. Each point corresponds to a trade exit in an OOS window.
Fold Boundary Markers
A vertical marker is placed at the start bar of each fold's test window (testRange[0]). Click a marker to select the corresponding fold.
Real Timestamps
If timestamp data is available, bar indices are mapped to actual Unix timestamps, giving the X-axis proper date/time labels. Falls back to synthetic timestamps if no real data is present.
Interactive Selection
Clicking near a fold boundary marker selects that fold across the entire panel — the fold table scrolls to the row, and the Fold Inspector updates.
Chart Controls
Mouse wheel zoom, click-drag pan, pinch-to-zoom on touch. Time scale and price scale are both adjustable.
Responsive Sizing
The chart auto-resizes using a ResizeObserver when the panel layout changes (e.g. when the user drags the center column divider).

Timestamp Handling

The equity curve component can display time on the X-axis in two modes:

Real Timestamps (preferred)
When the market data fetch returns actual UNIX timestamps, each bar index maps to a real calendar time. The chart shows proper date labels on the X-axis. The panel passes these via the timestamps prop.
Synthetic Timestamps (fallback)
If no timestamps are available, each bar is mapped to 1600000000 + bar × 60 seconds — a synthetic 1-minute grid starting from a fixed epoch. The chart is still usable but dates are not meaningful.
Reverse lookup:When a chart click needs to identify which fold was clicked, the component does a nearest-timestamp binary search to find the corresponding bar index, then matches it to the fold whose test window starts closest to that bar.

Reading the Stitched Curve

Positive
Consistent upward slope
The strategy generates positive OOS returns across all time periods. Strong robustness indicator.
Neutral
Flat with occasional gains
Some folds profitable, some break-even. Strategy may work in certain market regimes only.
Normal
Visible kinks at fold boundaries
Equity resets or jumps at each fold start. Expected — each fold starts from where the previous OOS session ended.
Negative
Steady decline
OOS performance is consistently negative. The strategy does not generalise. Review parameters or strategy logic.
Warning
IS equity much higher than OOS curve
Classic overfitting signature. Compare the IS vs OOS bar chart — IS bars will be much taller.