New to algo trading? Start here
The life of a strategy, in six steps.
Plain words first, and a line for people who already test strategies under each step. Scroll, and the picture follows.
An algo is a rule a computer can follow.
No gut feeling, no “it looks strong”. For example: if price breaks above the high of the first 30 minutes, buy. If it falls back to the low, get out. Otherwise sell at the close. Written like that, a computer can check it on years of data.
For pros
Every condition has to be computable at the entry bar from data up to that bar. “Strong”, “clean” or “trend day” are not rules until they are pinned to a number, and every way of pinning them is one more variant in your search.
A backtest replays the past.
The computer runs the rule over hundreds of past days and adds up what it would have made. The line that grows at the bottom is the equity curve: the running total, trade after trade.
For pros
Results in R, entries on the bar after the signal, the stop assumed first when stop and target sit inside one bar, costs on every trade, and the session calendar and contract rolls as they really were.
Every trade pays a toll.
Commission and slippage, the gap between the price you wanted and the price you got, are paid on every trade, winner or loser. A rule that earns a little per trade can earn nothing once the toll is paid. Here it is 0.08 R a trade.
For pros
Cost fraction = cost in ticks ÷ stop in ticks. Work it out before you test anything: around 0.1 R most intraday edges are gone, and tighter stops make it worse, not better.
One backtest is one roll of the dice.
If the past had gone a little differently, the same rule would have earned something else. These 50 lines are the same rule on 50 possible pasts. Your backtest is one of them, and you cannot tell which.
For pros
Judge the spread, not the line: the t-statistic of the average trade, the share of losing years, and the worst drawdown across resampled histories.
Try enough rules and one looks great by accident.
Here are 120 versions of the rule, all tested on random prices where nothing can work. Sorted by result, the best one still looks like a strategy. This is the trap behind most backtests you see online.
For pros
Compare a winner with the best of the same search run on shuffled data, not with zero. For N independent tries the best t-statistic of pure noise grows roughly like √(2 ln N): about 3 for 100 tries.
New data is the judge.
Lock the most recent part of the data away before you start. Choose the rule on the rest, then open the lock once. The lucky winner falls apart. A real edge carries on: small, noisy, but there.
For pros
Out-of-sample once, walk-forward when parameters are re-chosen, a placebo or random-entry control for every claim, and a record of every variant you tried, the failures included.