> For the complete documentation index, see [llms.txt](https://guida-2.gitbook.io/guida-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guida-2.gitbook.io/guida-docs/core-concepts/backtesting.md).

# Backtesting

**Backtesting** is the practice of running a strategy against historical market data to see how it *would* have performed. It's one of the most valuable tools available to any trader — and one of the easiest to misuse. This page explains how it works, what the numbers mean, and how to avoid fooling yourself.

## How backtesting works

When you backtest a strategy in Guida, the engine:

1. Takes your strategy's exact rules — triggers, actions, sizing, exits.
2. Replays historical price data as if it were happening live.
3. Simulates every trade the strategy would have made, in order.
4. Tracks the resulting balance over time and computes performance metrics.

The output is a detailed picture of how your idea would have navigated real, historical market conditions — the rallies, the crashes, and the long boring stretches in between.

## The metrics that matter

| Metric                   | What it measures                                    | How to read it                                                    |
| ------------------------ | --------------------------------------------------- | ----------------------------------------------------------------- |
| **Total return**         | Overall profit or loss across the test period.      | Higher is better — but never in isolation.                        |
| **Win rate**             | Percentage of trades that were profitable.          | A high win rate can still lose money if the losses are large.     |
| **Maximum drawdown**     | The largest peak-to-trough fall in your balance.    | The "could I stomach this?" number. Lower is calmer.              |
| **Equity curve**         | Your simulated balance plotted over time.           | A smooth, rising curve beats a jagged one with the same endpoint. |
| **Risk-adjusted return** | Return relative to the volatility taken to earn it. | Rewards strategies that make money *steadily*, not luckily.       |

> **The most misunderstood metric is win rate.** A strategy can win 90% of the time and still be a disaster if the occasional 10% loss wipes out all the small wins. Always read win rate alongside drawdown and return.

## The honest limits of backtesting

Backtesting is powerful, but it comes with real caveats that every serious strategist respects:

* **Past performance never guarantees future results.** A strategy that thrived historically can fail when market conditions change. History rhymes; it doesn't repeat.
* **Overfitting is the classic trap.** If you tweak a strategy until it looks perfect on past data, you've often just tailored it to that specific history — not to the future. A strategy tuned too tightly to the past tends to fall apart in the present.
* **Real-world frictions matter.** Fees, slippage (the gap between the price you expect and the price you get), and liquidity all affect real results. Good backtesting accounts for them; naive backtesting ignores them and flatters the strategy.

## How to backtest well

* **Test across different market regimes** — bull, bear, and sideways. A strategy that only works in a raging bull market isn't robust.
* **Prefer simple, explainable strategies.** If you can't say *why* it works in a sentence, be suspicious of a great backtest.
* **Watch the drawdown, not just the return.** The best backtest is one you'd actually have had the nerve to stick with.
* **Treat it as a filter, not a promise.** A good backtest earns a strategy the right to be paper-traded next — nothing more.

## Backtesting vs. paper trading

Backtesting looks *backward* at history. [Paper trading](/guida-docs/core-concepts/paper-trading.md) looks *forward* on live prices. They answer different questions, and you should use both: backtesting to check the idea is sound, paper trading to confirm it behaves as promised in today's market.

***

**Next:** [Paper Trading →](/guida-docs/core-concepts/paper-trading.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://guida-2.gitbook.io/guida-docs/core-concepts/backtesting.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
