VALYNOXSTRATEGY RESEARCH TECHNOLOGY
AlphaPrimeAlphaPrime
ACADEMY / Strategy generation

How to develop a trading strategy: 6 steps from hypothesis to test

Develop a trading strategy in a fixed order: write a hypothesis, turn it into rules a computer can run, collect enough completed trades, backtest with costs, check it on unseen data and judge it against limits you wrote down before looking. An idea that fails goes back to step one, not to a tweak.

By · Published · updated · Editorial policy

Contents
  1. How do you develop a trading strategy that can be tested objectively?
  2. How do you turn a market idea into exact rules?
  3. How much data is needed to develop a strategy?
  4. How do you backtest with realistic costs?
  5. How do you validate out of sample and avoid overfitting?
  6. How do you tell if a strategy is usable?
  7. Frequently asked questions
  8. References

How do you develop a trading strategy that can be tested objectively?

How to develop a trading strategy that can be tested: follow six steps in a fixed order. Write a hypothesis, turn it into exact rules, collect enough completed trades, backtest with realistic costs, check the frozen rules on data the search never saw, then judge pass or fail against limits you wrote before looking.

A hypothesis is one sentence that says what the market does and why, for example "after a strong close, the next day more often continues than reverses". The order matters because each step protects the next one. Skipping ahead is how most traders end up with a result they cannot trust. The background on what algo trading is and why most rules lose is in algo trading explained: what it is and what it costs; the wider research routine, from data to live trading, is in how to build a quantitative trading process step by step.

Six strategy steps run in one direction: hypothesis, rules, trades, costs, out-of-sample test and verdict. A failure at any check goes back to the hypothesis as a new idea, not as a tweak. Fail? Back to step one Six steps, one direction Hypothesis Rules Trades Costs OOS test Verdict Fail → new idea, not a tweak A failed check means a new idea. So: never patch the step that failed.
The six steps run one way. A failure at any check sends the idea back to the start as a new hypothesis, not to a small change of the last step.

How do you turn a market idea into exact rules?

A rule is testable only when a computer can act on it without a human choice, so every entry, exit and setting becomes a number or a condition that is true or false on each bar. "Buy strength" is an idea. "Buy at the next open when the close is above the close 20 bars ago" is a rule, and it uses the momentum indicator in its simplest form. Write the exit the same way, and write the one you take when the idea is wrong, not only the one you take when it works.

  1. Write the entry as a comparison between two numbers the bar data gives you.
  2. Write the exit as a comparison too, and decide whether it fires on the same bar or the next one.
  3. Give every setting a range you would accept, not one value. A lookback of 15 to 30 bars is a hypothesis; exactly 23 bars is a coincidence waiting to happen.
Three vague ideas rewritten as exact rules: buy strength becomes close above the close 20 bars ago, exit on weakness becomes close below the close 20 bars ago, and avoid quiet days becomes skip if the range is under 1 percent Make every idea a number A program checks it on every bar Idea Exact rule Buy strength Exit on weakness Avoid quiet days Close > 20 bars ago Close < 20 bars ago Skip if range < 1% A rule needs no human choice. So: write entry and exit as numbers.
Each vague phrase on the left has one exact counterpart on the right that a program can evaluate on every bar.

How much data is needed to develop a strategy?

Enough data is measured in completed trades across more than one kind of market, not in calendar years. Six years of daily bars hold about 30 trades for a rule that trades every few months and several hundred for a rule that trades several times a week. The first sample is a hint; the second can be judged. The reason is simple: an average built from 30 trades moves a long way when two or three of them change, and you need four times as many trades to make that average twice as steady.

Check the years as well as the count. If every trade came from one long uptrend, a rule that is simply long most of the time will pass for the wrong reason. Look for a trending stretch, a sideways stretch and a sharp sell-off inside the history before you trust anything.

The same six years of daily bars drawn twice: a rule that trades every few months gives about 30 trades, only a hint, while a rule that trades several times a week gives hundreds of trades, enough to judge the average trade Count trades, not years Same six years, two example rules Every few months ≈30: hint Several times a week 300+: judge Same six years of daily bars 30 trades is a hint, not a result. So: count trades before judging.
The same six years give one rule a thin sample and another rule a usable one. Trades are the unit of evidence, not years.

How do you backtest with realistic costs?

Commission, slippage and next-bar execution go into the very first run, because a rule that trades often looks best before costs and worst after them. Slippage is the gap between the price the backtest assumed and the price you would actually have received. Next-bar execution means a decision made on the close of one bar is filled on the next bar, since you cannot trade a price that has already printed. The number to watch is the average trade after costs, compared with the round-trip cost of one entry and one exit; the free win rate and expectancy calculator gives that figure from win rate, average win and average loss.

Hypothetical example

A rule shows a gross average trade of $14. Commission is $4 per round trip and slippage one tick each side is $6, so the round-trip cost is $10 and the net average trade is $4. Double the slippage and the net average trade becomes −$2. This rule depends on cheap fills, so it goes back to the hypothesis step.

How do you validate out of sample and avoid overfitting?

The best result among many tried candidates is inflated by selection, so the rule is frozen, run on data the search never saw, and judged against a drop limit written in advance. Overfitting is tuning a rule so closely to one stretch of history that it describes the noise of that stretch instead of a repeatable pattern. Bailey, Borwein, López de Prado and Zhu (2014) show that the more variants you try, the more the winner's backtest overstates what follows. How to split the history and how much out-of-sample is enough is covered in in-sample vs out-of-sample: how to split the data.

The box below shows what selection looks like in practice. The run by AlphaPrime (Valynox) tested NQ daily bars from 2019-01-02 to 2025-06-30, long and short, one contract, with commission and slippage charged on every trade. It uses a Momentum rule as its only entry and exit, a stand-in for whatever idea you test, not the subject of this article. The result is the one candidate the search kept out of roughly a thousand it tried, chosen for its return against its drawdown. Picking the kept one after the fact flatters it: this is what the best of many looks like, not what the rule earned or what a reader can expect.

Source: AlphaPrime product engine (CPU), run 2026-10-31. NQ daily bars, 2019-01-02 to 2025-06-30, long and short, 1 contract, $20 commission and $10 slippage per trade.

NumberResult
Net profit (closed trades)$249,575
Max drawdown$93,215
Trades60
Win rate60%
Profit factor1.828
Average trade$4,159.58
Time in market92.48%

Two lines in the box are the ones step three and step five care about. Sixty trades is a thin sample, so the average trade could move far if a few trades changed. And 92.48% time in market on an index future over a period that was mostly rising means part of the result is the market, not the rule. Only the stretch after the out-of-sample boundary in the figure can tell how much.

Follow the equity curve and the drawdown band across the out-of-sample boundary. The slope and drawdown depth after that line are the ones to judge; the part before it helped choose the candidate.
Follow the equity curve and the drawdown band across the out-of-sample boundary. The slope and drawdown depth after that line are the ones to judge; the part before it helped choose the candidate. NQ · daily · 2019-01-02 to 2025-06-30 · CPU engine backtest

How do you tell if a strategy is usable?

A strategy is usable when its after-cost average trade, its drawdown relative to the account and its out-of-sample behaviour each clear a limit you wrote down before the test, and it is not usable when any one of them fails. Harvey and Liu (2015) make the same point from the research side: a result has to be discounted for the number of tests behind it, which is easiest when the limits exist before the tests. In the AlphaPrime run above, the drawdown is more than a third of the net profit, which a trader with a small account would have written down as a fail before seeing the curve. That kind of pre-written limit is what strategy validation in AlphaPrime holds: the thresholds are typed in before the search runs, and a candidate that fails an early check never reaches the later ones.

CheckUsableNot usable
Average trade after costs vs round-trip costSeveral times the costNear or below the cost
Max drawdown vs account sizeWell under the cushion you can holdClose to the account size
Out-of-sample share of in-sample average tradeAbove your written drop limitSign flips
Trades countedHundredsUnder about 30
Profit spread over quartersMost quarters positiveOne quarter made the result
A table of five checks written before the test: edge versus cost, drawdown, out of sample, trades and quarters, each with what usable looks like and what not usable looks like; one failed row means the strategy is not usable Write the limits first One failed row means not usable Check Usable Not usable Edge vs cost Drawdown Out of sample Trades Quarters Several × cost Well inside Above limit Hundreds Most positive Near cost Near account Sign flips Under 30 One made it Limits set after a test prove nothing. So: fill this table in before testing.
Fill this table in before you run the test. Then the result either clears every row or it does not.

The checks that follow once a strategy has cleared this table, including how it behaves across different market conditions, are in five checks before you trust an algo strategy that works consistently. If you are choosing software to run this process, the settings that matter, such as cost inputs and out-of-sample support, are listed in the algo trading software features that actually matter. Your next step: take one idea you already trade by feel, write its hypothesis and its five limits on one page, and only then open the backtester.

Frequently asked questions

How do you develop a trading strategy from scratch?

Start with one written sentence about what the market does and why. Turn it into entry and exit conditions a computer can check on every bar, collect enough completed trades across different market conditions, and backtest with commission, slippage and next-bar execution from the first run. Then freeze the rules, test them on data the search never saw, and compare the result with limits you wrote down before looking.

How much data is needed to develop a trading strategy?

Count completed trades, not years. Fewer than about 30 trades is a hint; a few hundred trades across a trending, a sideways and a falling stretch is a sample you can judge. A rule that trades rarely needs more years, or a walk-forward design that produces more out-of-sample trades from the same history.

How do you avoid overfitting a trading strategy?

Test settings as ranges rather than single values, keep the number of tuned settings small relative to the trade count, and never change a rule after seeing its out-of-sample result. The best candidate from a large search is always inflated by selection, so judge it against a drop limit written before the test, and reserve a final block of data that is tested exactly once.

How do you tell if a trading strategy is usable?

It clears every limit you wrote in advance: an after-cost average trade several times the round-trip cost, a maximum drawdown well inside the account you can hold, an out-of-sample result above your drop limit, hundreds of trades and profit spread across most quarters. One failed row means the idea goes back to the hypothesis step.

References

  • Bailey, D. H., Borwein, J., López de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458–471.
  • Bailey, D. H., Borwein, J., López de Prado, M., & Zhu, Q. J. (2017). The Probability of Backtest Overfitting. Journal of Computational Finance, 20(4), 39–69.
  • Harvey, C. R., & Liu, Y. (2015). Backtesting. The Journal of Portfolio Management, 42(1), 13–28.