Stock research guides · Guide 10 of 10
From trading idea to testable rules: strategy specs and honest backtesting
How written rules make a strategy inspectable, what separates a hypothesis from a tested result, and what to check before trusting any backtest.
Key takeaways
- A strategy is a hypothesis until precise entry and exit rules have been tested.
- Trend-following and dip-buying rules express opposite beliefs about what comes next.
- Judge a backtest by its period, costs, drawdowns and results outside the data used to build it.
- Research, testing and execution are separate decisions: a good backtest is not by itself a reason to trade.
Trading ideas often begin as a phrase such as "follow the trend" or "buy the dip", and a phrase cannot be tested. This guide shows how to write an idea as rules precise enough to test, what a backtest can and cannot tell you, and why a tested result is still separate from a decision to trade.
From an idea to a testable rule
An idea becomes a strategy when every decision it implies is written down. A testable rule fixes five things:
| Element | What it fixes | Example |
|---|---|---|
| Instrument | Which security, on which exchange | One listing of one share |
| Data | What the rule reads | Closing prices |
| Time frame | How long each bar lasts | Daily bars |
| Entry | When a position opens | A close above the 50-period average |
| Exit | When it closes | A close below that average |
Written this way, the idea becomes a hypothesis: a claim that could turn out to be wrong. Anyone applying the rule to the same data gets the same trades, so results can be checked. A vague idea can never fail a test, which is why it can never pass one.
Take the idea "buy shares that are going up". Going up since when, measured how, and sold when? One precise version: on daily bars, buy after a close above the 50-period simple moving average and sell after a close below it. Every trade now has a checkable date and price.
Trend rider and Dip buyer: opposite hypotheses
dotQuant's two built-in examples disagree about what comes next.
Trend rider uses daily bars and a 50-period simple moving average, entering on a close above the average and exiting on a close below. Its hypothesis is that a price above its recent average tends to keep rising long enough to be worth following, the idea behind trend following and price momentum.
Dip buyer enters when the daily close is below its 10-period average and exits when the close is back above. Its hypothesis is the opposite: a short-term fall below the recent average tends to reverse, a belief called mean reversion.
| Aspect | Trend rider | Dip buyer |
|---|---|---|
| Belief | Moves tend to continue | Short falls tend to reverse |
| Entry | Close above its 50-period SMA | Close below its 10-period average |
| Exit | Close below that SMA | Close back above that average |
| Can fail when | Prices move sideways | A fall keeps falling |
Trend rider can fail through whipsaws. Take a hypothetical share swinging between 98 and 102 around an average near 100: the rule keeps buying near 101 and selling near 99, and five such round trips lose about 10 per share before costs.
Dip buyer can fail because a falling price need not recover. Take a hypothetical share sliding steadily from 100 to 60: its closes stay below a lagging 10-period average, so the rule can hold on through much of the fall, and nothing in it limits the loss before a close gets back above. Conditions that suit one rule tend to hurt the other, so a single test period can flatter either.
What to check before trusting a backtest
A backtest applies fixed rules to historical data bar by bar, as if they had been followed at the time, and records the hypothetical trades, costs and account value. It answers a narrow question: how would these exact rules have behaved on this data, under these assumptions?
Backtested results, like past performance, do not guarantee future results. Prices can fall as well as rise, and a rule that worked on one stretch of history can fail on the next.
The test period and market regimes
A result covers only the market it was tested on: a trend rule tested on one long rise is seeing its best case. Look for rising, falling and sideways stretches, and compare the result with simply holding the instrument over the same dates.
Costs and slippage
Every trade pays something: commission where charged, the bid–ask spread, and slippage, the gap between the price a rule expects and the price it gets. Costs grow with the number of trades: a hypothetical rule making 50 round trips a year and losing 0.2% on each gives up roughly 10% a year before it earns anything.
Fills at the next open, not the signal close
A daily close is only known once the session has ended, so a rule that reads it cannot also have traded at it. Filling at the signal bar's close uses information not yet available, known as look-ahead bias, and can flatter results. A realistic test fills at the next bar's open, which may have gapped away from that close.
Drawdowns
Maximum drawdown is the largest percentage fall in account value from a peak to a subsequent low.
Drawdown = (peak value − subsequent low) ÷ peak valueGain needed to recover = drawdown ÷ (1 − drawdown)A hypothetical account that rises to 10,000 and falls to 8,000 has a 20% drawdown and needs a 25% gain to get back. Check whether drawdown was measured on every bar or only on closed trades, which hides losses on open positions.
The number of trades
A handful of trades proves little: with five trades, one lucky exit can decide the result. Check whether the conclusion survives removing the single best trade.
Overfitting and out-of-sample testing
Try enough settings and one will look good by chance. Test every average from 5 to 100 periods, keep the best, and part of what you found is noise in that history: overfitting. The defence is an out-of-sample test on data that played no part in choosing the rules; a result that collapses there was probably fitted to the past.
Survivorship bias
Testing only instruments that still exist leaves out companies that failed and were delisted, which skews results towards winners. Choosing a share to test because its chart looks good in hindsight is the same trap.
Popularity is not evidence
Rankings of top or trending strategies measure attention, not reliability. A strategy can climb a list because a recent stretch suited it, while those that did badly drop from view: the regime problem and survivorship bias again. Treat a popular strategy as one more hypothesis and ask for the same evidence.
Research, testing and execution are separate decisions
Understanding a rule, testing it and trading it are three decisions, each needing its own reasons. A tested result shows how rules behaved in the past, not whether trading them suits your circumstances, what position size is sensible or how you would cope with a real drawdown.
Before any execution, check what your broker account is permitted to trade, since permissions differ by account and instrument type, and understand the risks: you can lose some or all of the money you invest.
Putting it into practice on dotQuant
On a symbol page, the "Strategies" view opens a library titled "Strategies" ("Entry and exit rules, written in plain English"), marked "Early access — this feature is under active development." Its sections are "All", "Favorites", "My strategies", "Built-in" and "Community", whose "Top" and "Trending" lists stay locked until you sign up.
Anyone can review a strategy, including "Trend rider" and "Dip buyer", and "View spec" shows the compiled specification, so you check the rule itself rather than infer it from the name. "Backtest this", with "Trade quantity" and "Starting capital", needs an account. A dotQuant backtest runs over the chart's visible range, so changing the window tests a different period. It charges costs on every fill, fills at the next bar's open, marks drawdown to market on every bar and compares the result with buying and holding over the same window; the other checks above remain yours to apply. See writing a strategy, running a backtest and reading backtest results.
Execution is a separate step. A strategy can later run live on closing bars for a signed-in user, and orders pass through to your own broker account only with your approval. Buying and selling needs both an account and a connected broker; guests cannot place orders. Without an account, prices are end-of-day; live intraday prices also need the dotQuant desktop app and your own Interactive Brokers market-data subscriptions.
A short routine keeps research in order, with tools supporting your judgement rather than replacing it:
- The business first: what the company sells and how it makes money (how to research a company).
- Then the finances: the Key Metrics panel (documentation), read with the guides to valuation ratios and financial health.
- Then question the analysts' assumptions: the AI analysts are AI-generated research perspectives with fixed investing styles, not human analysts. Their confidence is not a probability of profit and their labels are not recommendations, so compare their methods and assumptions, not their scores (documentation).
- Then the strategy evidence: the written spec first, then a backtest judged by the checks above.
Common questions
Does a profitable backtest mean a strategy will work?
No. It shows how fixed rules would have behaved on past data under particular assumptions. Optimistic fills, missing costs, a favourable period or overfitting can all make a backtest look better than live trading turns out to be.
What is look-ahead bias in backtesting?
Using information in a test that was not available when the decision would have been made. Filling a trade at the close that generated the signal is the classic case; using financial figures before their publication date is another.
Further reading
- How to read a stock chart: how the averages in both built-in rules are calculated and why they lag.
- Economic moats, management quality and macro momentum: why business growth and price momentum can diverge.
- How to research a company: the first step of the routine above.
- FCA InvestSmart: the UK regulator's guidance on investment risks.
- SEC, Beginners' Guide to Financial Statements: a primer for the finances step.