Introduction
A random baseline test is a way of asking whether a trading strategy has an edge, by comparing its result against the results that chance alone would produce from the same strategy. The mechanism is simple: take the strategy you wrote, keep everything about it intact — the same indicators, entry conditions, position sizing, stop-loss and fees — but move the moment of entry to randomly chosen bars in the same data. Repeat that a few hundred times and you have a distribution of results a strategy with no predictive power would have produced. The strategy's own backtest is then located inside that distribution and reported as a percentile. A result at the 50th percentile means half of the random replications did at least as well, which means the strategy has not demonstrated anything at all. A result at the 99th percentile means fewer than one in a hundred random replications matched it, which is what evidence of an edge looks like.
This matters because a backtest does not fail loudly when it is meaningless. A rule that fires at random still produces a profit factor, a win rate, a Sharpe ratio and an equity curve, and on a favourable stretch of data those numbers routinely land inside the range that grading systems call “good”. The strategy did not pass a test; it produced numbers that look like passing.
Why backtest numbers can be produced by luck
Consider a strategy with no predictive power whatsoever: enter when a fast moving average crosses above a slow one, exit on the next opposite cross, size by a fixed fraction of equity. Run it on two years of hourly crypto candles and you will get a trade list, a win rate, a profit factor and a maximum drawdown. None of those numbers is a measurement of skill — they are a measurement of what happened, once. The error is to read them as a measurement ofskill.
The second problem is that the search itself selects for noise. When you try a hundred variations of a rule and keep the one with the best backtest, the best backtest is partly the best fit to that particular stretch of history. This is the same mechanism as picking the highest-scoring student on a single exam, and it is why a strategy that looked unbeatable on the sample can fall apart the moment it meets data it has not seen. The overfitting and data-snooping section of our guide to quantitative trading covers the mechanics; this article is about the measurement that catches it.
What the test actually does
One more thing to keep in mind while reading the rest: the baseline is not a verdict on the strategy, it is a verdict on the evidence you have produced so far. A strategy can pass it and still be a poor trade — it might be a real edge that is too small to survive the fees of the exchange you would trade it on, or it might be a genuine edge that will not survive the regime it was fitted in. What the test does rule out is the cheapest and by far the most common explanation for a good-looking backtest, which is that the entries were no better than a coin flip and the sample was kind. Everything after this section is about narrowing what is left.
Five steps, and every one of them matters more than it looks:
- Run the real strategy once over the same data with the same parameters, recording the final return, the trade list and the per-trade statistics.
- Take the entry signal and discard its timing. The number of trades, the direction of each one and the holding period are all preserved. Only when the entry happened is replaced with a random bar.
- Re-run the full simulation on those random entries — same position sizing, same stop-loss, same take-profit, same fee schedule. This is the step that is usually skipped and the reason the test is usually wrong.
- Repeat a few hundred times, collecting the distribution of final returns.
- Locate the real result inside that distribution and report the percentile:
where is the set of random-entry results and is what the strategy actually returned. The formula is trivial; the discipline is in steps 2 and 3.
How to read the percentile
| Percentile | What it means | What to do next |
|---|---|---|
| 95 and above | Almost no random replications matched this. The strategy probably has a real edge — and probably also has some overfitting left in it. | Validate out-of-sample before trading it. |
| 75–95 | Better than most random versions, but a favourable stretch of data could plausibly explain it. | Re-run on a different period and a different instrument before you trust it. |
| 40–75 | Indistinguishable from chance. A coin flip does this about half the time. | Do not trade it. Fix the strategy or discard it. |
| Below 40 | Worse than random entries — the rules are actively hurting, most likely because of costs or because the exit logic is mismatched to the entry. | Check the cost model before changing the logic. It is frequently the costs. |
Note what the percentile does not say. It is not a probability that the strategy will make money, and it is not a confidence interval. It answers exactly one question — how often would a strategy with no edge have done this well? — and a strategy can pass it and still be a bad trade for reasons that have nothing to do with the entry points.
Why the same engine must be reused
The single most common way to get this test wrong is to compute the baseline with different code than the strategy itself. A separate simulator means a different fill assumption, a different fee treatment, a different stop-loss handling, a different rounding of quantities — and any of those differences shows up as a shift in the whole distribution. The percentile then measures your two implementations against each other rather than measuring the strategy against chance.
In TodoAI the baseline reuses the same backtest engine and the same intent sequence that the real strategy produces. The rule evaluation is skipped and nothing else changes: the fills, the fees, the stop-loss, the take-profit and the position accounting are the same code paths in the same run. That is the only way for the comparison to isolate the one thing it is supposed to isolate — the timing of the entries.
What a random baseline does not tell you
It is worth being precise about the limits, because a test that is oversold is as damaging as one that is skipped. A random baseline catches the case where the entries carry no information. It does not catch a strategy whose entries are informative but whose exits leak money; it does not detect a curve-fitted indicator threshold that happens to work on this data and no other; it says nothing about whether the edge will survive the costs, the slippage and the market structure of the instrument you intend to trade it on. And because every random replication still uses your exit logic, a broken exit drags the whole distribution down with it. This is why the baseline is the first layer of validation and not the only one, and also why it is the cheapest: pure CPU, no market data beyond what you already have, and no LLM calls.
This is why the baseline is the first layer of validation and not the only one. It is also the cheapest: it is pure CPU, no market data beyond what you already have, and no LLM calls. On a strategy with a hundred bars of history it runs in seconds, which is why it can be applied to every candidate rather than only to the final one.
The three layers of validation
Validating a strategy is a stack of three tests, ordered by cost, and the order is not arbitrary. The random baseline is first because it is the cheapest and the most likely to end the conversation: if the entries carry no information, there is nothing for the expensive tests to examine, and no point spending minutes on a strategy that chance can explain. The second layer is walk-forward validation, which asks whether the edge survives being re-fitted on one period of history and applied to a later period it has never seen — the only test that speaks to the question that actually matters, which is what happens after the backtest ends. The third is Monte Carlo permutation, which shuffles the order of the trades to find how much of the result depends on the sequence rather than the trades: a strategy whose edge vanishes when the winners and losers are reordered was never an edge, it was a favourable ordering. Each layer assumes the previous passed.
| Layer | Question it answers | Cost |
|---|---|---|
| Random baseline | Do the entry points carry any information at all, or would chance have produced this? | Seconds. Pure CPU. |
| Walk-forward | Does the edge persist when the strategy is re-fitted on earlier data and applied to later data it has never seen? | Minutes to hours. |
| Monte Carlo permutation | How sensitive is the result to the order of the trades, rather than their entries? | Minutes. |
Run them in that order. The baseline is the cheapest test and the one most likely to end the conversation early — there is no point walk-forwarding a strategy that chance can explain, and no point tuning a curve-fit that fails the baseline. Each layer assumes the previous one passed.
Running it on your own strategy
The practical sequence, if you are doing this by hand or wiring it into your own backtester:
- Record the strategy's own result: final return, trade count, win rate, profit factor, maximum drawdown.
- Extract the entry signals and their directions from that run — not from a separate scan of the data.
- For each of N repetitions, draw a random bar for every signal and re-run the identical simulation.
- Collect the final returns and sort them. The strategy's percentile is the share of them it beat.
- If the percentile is under about 75, stop and fix the strategy. If it passes, continue to walk-forward on data the strategy has never seen.
Two practical warnings. Use enough repetitions for the tail to be meaningful: with only twenty random runs you cannot distinguish the 95th percentile from the 90th, because both are “one run that beat it”. And keep the number of entries fixed — if the random version takes a different number of trades, you are comparing two different strategies rather than two timings of the same one.
Conclusion
A backtest tells you what happened once. A random baseline tells you whether that could have happened by accident, which is a different and much more useful question — because the strategies that fail it are the ones that were never strategies at all, only shapes in historical data that happened to look like an edge. The test is cheap enough to run on every candidate, precise enough to produce a number you can argue about, and honest enough that failing it is a useful result rather than a wasted afternoon.
None of this replaces the risk controls that keep a losing streak from ending the account; the risk management guide covers those. It replaces a more common habit: reading a good equity curve as proof of an edge. Generation is table stakes; vetting is the part nobody ships.
Sources
- Overfitting — why the best of many tried variations is partly fitted to the sample it was chosen on.
- Backtesting — the mechanics of replaying a strategy over historical data, and its standard failure modes.
- Monte Carlo method — the permutation technique used for the third validation layer above.
- Percentile — the definition of the statistic the test returns.