How to start mechanical trading: a step-by-step guide
From a vague idea to a system you are willing to trade: writing rules, getting data, testing honestly, trying to break it, sizing the risk and going live small. Eight steps, in order.
Most people who try mechanical trading start with the backtest. That is step four. The first three steps decide whether the backtest means anything. Here is the order I would follow if I were starting today.
1. Start with a reason, not a pattern
A good idea has an explanation that would make sense to someone who never saw the chart. Markets trend because large orders take days to fill. The open is volatile because overnight information gets priced at once. Ranges break because stops cluster outside them.
You don’t need the explanation to be proven. You need one, because an idea with a reason is less likely to be a coincidence you found by staring at charts. Patterns without a reason are the easiest things in the world to find, and the hardest to keep.
2. Write the rules until nothing is left to judgment
Entry, stop, target or exit, time filters, what happens on news days, what happens if two signals appear, position size. Every rule exact enough that a stranger could follow it. If a rule contains “strong”, “clean” or “clear”, it isn’t finished.
If you can’t explain the rule to a computer, you can’t test it. If you can’t test it, you can’t know it.
3. Get honest data
Use data for the market you will actually trade, at the resolution the rules need. Intraday rules need intraday data. Futures need a sensible way to handle contract rolls. Include the bad years. A test that starts after a crash is a test that never met one.
4. Test with costs, then look at the losing side
Run the rules over the full history and include commissions and realistic slippage from the start. Then look past the net profit. How many trades? What is the expectancy per trade, and is it larger than a tick or two of slippage? What is the deepest drawdown, how long did it last, and what was the longest losing streak?
Be suspicious of a beautiful result. Campbell Harvey and Yan Liu showed in “Backtesting” (Journal of Portfolio Management, 2015) that when many variations have been tried, a reported Sharpe ratio has to be cut, and the weaker the result the bigger the cut. A strategy that only just looks good after many tries often isn’t.
5. Try to break it
- Change each parameter a little. If 20 works and 18 and 22 don’t, you found noise, not an edge.
- Split the history. Build on one part, test on a part the rules never saw.
- Test other markets or periods with the same logic. A real effect usually shows up in more than one place.
- Remove the best trades. If the edge disappears without the top 1% of trades, it depends on luck you can’t count on.
- Shuffle the order (Monte Carlo). The same trades in a different order can produce a much worse drawdown. Plan for that one, not the one you happened to get.
This is the step most people skip, and it is the one that matters most. David Bailey, Jonathan Borwein, Marcos López de Prado and Qiji Jim Zhu showed in “The Probability of Backtest Overfitting” (SSRN 2326253) that standard checks like a single hold-out period are unreliable for strategy backtests, and that the more configurations you try, the more likely your best one is overfit.
6. Size the risk for the worst case, not the average
Take the deepest drawdown from the test and from the Monte Carlo runs, and size so that surviving it is comfortable, not just possible. If you trade a prop account, the firm’s drawdown limit is the number that matters. A strategy with an edge can still fail an evaluation if its normal drawdown is larger than the limit.
7. Go live small, and compare against the test
Start with the smallest size that is still real money or a sim that is executed exactly like live. The goal is not profit yet. It is to check that live trades look like the test: similar fills, similar slippage, similar frequency of signals. Differences here are information about your assumptions.
8. Review the process, not the last trade
Keep a record of every trade and every rule break. Review in batches: after 30, 50, 100 trades, not after each one. Ask two separate questions: did I follow the rules, and is the system behaving within the range the test showed? A losing trade that followed the rules is not a mistake. A winning trade that broke them is.
A short checklist
- The idea has a reason that makes sense without the chart.
- Every rule could be followed by a stranger.
- The test includes costs, bad years and enough trades to mean something.
- Small parameter changes don’t destroy the result.
- It still works on data it was not built on.
- Risk is sized for the worst drawdown you have seen, plus room.
- Live results are compared to the test, in batches.
None of this guarantees a profitable system. It gives you a way to find out whether you have one, before the market tells you the expensive way. Nothing here is investment advice.
— Alon