> ## Documentation Index
> Fetch the complete documentation index at: https://docs.askfutures.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Backtesting

> What a backtest is, the test window in plain English, status, the metrics that matter, and the artifacts you can export.

A **backtest** replays your strategy over real historical prices, one bar at a
time, and tells you how it would have performed. You don't run anything yourself —
once a strategy exists, just say *"backtest it"* (or click **Run backtest** on the
strategy card), and AskFutures does the rest.

<Note>
  The AI only translated your idea into rules. The backtest itself is fixed,
  deterministic code — real [TA-Lib](https://ta-lib.org/) indicators plus a
  numerical simulator. Same rules + same data = the same numbers, every time. See
  [Is the backtest real?](/concepts/is-the-backtest-real)
</Note>

## What a backtest does

<Steps>
  <Step title="Loads real data for your symbol">
    Back-adjusted continuous contracts at your chosen bar size (1-minute,
    5-minute, or daily), updated daily from the vendor feed.
  </Step>

  <Step title="Replays history bar by bar">
    The simulator walks forward in time, checking your entry rules, exit rules,
    and filters on each bar — no peeking ahead.
  </Step>

  <Step title="Models your trading costs">
    Each fill is charged slippage (default **1 tick**) and commission (default
    **$1/side** micro, **$2.50/side** full-size). Reported P\&L is net of both.
  </Step>

  <Step title="Reports the results">
    Trade count, P\&L, win rate, drawdown, and more — plus an exact record of every
    trade you can download.
  </Step>
</Steps>

## The test window

A backtest always covers a specific stretch of history. You can describe it the
way you'd say it out loud:

* *"backtest the last 2 years"*
* *"test it since 2020"*
* *"year to date"*
* *"from January 2022 to June 2023"*

AskFutures resolves your phrase to **exact start and end dates**, measured against
the latest available data date. *"Last 2 years"* today and *"last 2 years"* next
month cover different windows — but each run records the precise dates it used, so
results are always reproducible. Resolving the phrase only picks dates; it never
changes your trading logic.

<Note>
  If you don't specify a window, AskFutures defaults to the **last 1 year**. Every
  backtest result shows the exact date range it covered.
</Note>

<Warning>
  **"Lookback" and "period" mean two different things — don't mix them up.**

  * The **test window** is *how far back the backtest runs* (e.g. "since 2020").
  * An **indicator period / length** is *how many bars an indicator looks back*
    (e.g. a "20-period EMA").

  Saying "use a longer lookback" is ambiguous. Say *"test a longer window"* or
  *"use a longer EMA"* so AskFutures changes the right thing.
</Warning>

## Backtest status

Every strategy carries a status so you always know where it stands:

| Status         | What it means                                                                                                                                   |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| **Not tested** | The strategy exists but hasn't been run yet — no numbers.                                                                                       |
| **Passed**     | The backtest ran cleanly and produced results.                                                                                                  |
| **Failed**     | The run couldn't complete — usually a rule that can't be evaluated, or a window with no data. The strategy card explains why so you can fix it. |

<Tip>
  A "failed" backtest is a build problem, not a bad strategy. It means the rules
  couldn't be simulated — adjust the idea in chat and run it again.
</Tip>

## The metrics

After a successful run, the strategy card shows the headline numbers:

<CardGroup cols={2}>
  <Card title="Trade Count" icon="hashtag">
    How many trades the rules generated over the window. Very low counts are hard
    to trust; very high counts can mean over-trading.
  </Card>

  <Card title="Total P&L" icon="sack-dollar">
    Net profit or loss across all trades, after modeled slippage and commission.
  </Card>

  <Card title="Avg P&L / Trade" icon="divide">
    Total P\&L divided by trade count — the per-trade edge. A few cents either side
    of zero usually means there's no real edge once costs are paid.
  </Card>

  <Card title="Win Rate" icon="percent">
    The share of trades that closed profitable. High win rate alone doesn't mean
    profitable — small wins and large losses can still lose money.
  </Card>

  <Card title="Max Drawdown" icon="arrow-trend-down">
    The largest peak-to-trough drop in cumulative P\&L — the worst stretch you'd
    have had to sit through. This is your pain tolerance check.
  </Card>
</CardGroup>

Ask for more and AskFutures will surface **extended metrics** too — for example
average win vs. average loss, profit factor, the long/short split, exit-reason
breakdowns (how often you left via stop, target, trailing stop, time, session
close, or signal), and per-direction performance.

<Warning>
  Backtest results are **hypothetical and simulated** — no real trades were
  placed. Simulated results are designed with the benefit of hindsight and can
  under- or over-state live outcomes. **Past performance does not guarantee future
  results. Always test before you trade.**
</Warning>

## Exportable artifacts

For deeper review, you can take the raw output with you:

<AccordionGroup>
  <Accordion title="Trade list" icon="table-list">
    Every trade the backtest took: entry and exit time, direction, prices, the
    reason it exited, and the P\&L for that trade. Download it to audit the numbers
    yourself or pull them into your own spreadsheet.
  </Accordion>

  <Accordion title="Signal data" icon="wave-square">
    The per-bar values behind the rules — indicator readings and when each
    condition fired. Useful for power users who want to see *exactly* why a trade
    triggered (or didn't). The strategy card's **Download trades with signal info**
    bundles both together.
  </Accordion>
</AccordionGroup>

<Tip>
  Because the engine is deterministic, the exported trade list will always
  reconcile to the headline metrics. If you re-run the same strategy over the same
  window, you'll get the identical file.
</Tip>

## Next steps

<CardGroup cols={2}>
  <Card title="Is the backtest real?" icon="shield-check" href="/concepts/is-the-backtest-real" />

  <Card title="Optimization" icon="sliders" href="/concepts/optimization" />

  <Card title="Strategies" icon="diagram-project" href="/concepts/strategies" />

  <Card title="Build a strategy" icon="hammer" href="/guides/build-a-strategy" />
</CardGroup>
