Building Strategies from Rule Blocks
Turn "gut feel" into rules: buy when one condition is true, sell when another is. Snap a few blocks together and let historical prices give you the answer.
Key takeaways
- 1A complete rule set includes an entry condition, an exit condition and a stop-loss. You can't skip any of them.
- 2Rules must be fixed in advance so you don't "change the question after seeing the answer" during a backtest.
- 3The same rules perform very differently in different markets: trend rules struggle in ranges, mean-reversion rules struggle in one-way trends.
- 4Compare backtest results with buy-and-hold, and look at both return and maximum drawdown.
Check your understanding
Get every question right to complete this lesson
1.Which of these is a clear rule you can backtest?
2.In what kind of market do trend rules like moving average crossovers struggle most?
3.In a one-way rally, a rule returns +54% while buy-and-hold returns +80%, but the rule's maximum drawdown is only 6%. What does this tell you?
Text version · Quant Basics, lesson 1: “Building Strategies from Rule Blocks”
Turn "gut feel" into rules: buy when one condition is true, sell when another is. Snap a few blocks together and let historical prices give you the answer.
Turn a hunch into a rule
“It looks like it's about to go up” can't be tested. A trading rule has to be checkable candle by candle: condition + action + stop-loss. Once the rule is fixed, past prices can give an objective answer.
Every rule has its “home turf”
Trend rules capture big moves in one-way markets and get whipsawed in ranges; mean reversion rules are the opposite. Run a backtest across different markets to see where a rule breaks down.
Compare with buy and hold
In a steady uptrend, a rule that trades in and out often can't beat simply holding. Its value is in stepping aside during declines, with a smaller maximum drawdown. Look at return and drawdown together.
Key takeaways
- A complete rule set includes an entry condition, an exit condition and a stop-loss. You can't skip any of them.
- Rules must be fixed in advance so you don't "change the question after seeing the answer" during a backtest.
- The same rules perform very differently in different markets: trend rules struggle in ranges, mean-reversion rules struggle in one-way trends.
- Compare backtest results with buy-and-hold, and look at both return and maximum drawdown.
Try it yourself
You can do these exercises in this lesson's interactive simulation:
- In “Steady uptrend”, use “Price × MA” (20-day): what are the rule's return and buy and hold's return? And the maximum drawdown?
- Keep the same rule and switch to “Sideways range”: how many trades did it make? What's the rule's return?
- In “Sideways range”, switch to the RSI block (default 7-day, 30 / 70): what's the return now? And back in “Steady uptrend”?
- Switch to “Wild swings” and use “MA crossover”: what's the rule's return with no stop-loss, a 5% stop and a 2% stop?
Quiz and explanations
- 1. Which of these is a clear rule you can backtest?
- Answer: Buy when the close crosses above the 20-day moving average.Only a clear condition that can be checked candle by candle can be tested against history.
- 2. In what kind of market do trend rules like moving average crossovers struggle most?
- Answer: A choppy range.In a range, signals keep appearing and failing, and fees and small losses keep piling up.
- 3. In a one-way rally, a rule returns +54% while buy-and-hold returns +80%, but the rule's maximum drawdown is only 6%. What does this tell you?
- Answer: It didn't beat holding, but the drawdown was much smaller, so it's a trade-off.Rules often give up some return for a smaller drawdown. Whether that's worth it depends on which you care about more.
Terms in this lesson
- backtest (Backtest): Simulating rule-based trading on historical data to see how a strategy would have done.
- maximum drawdown (Max Drawdown): The biggest drop from an equity peak to the lowest point that follows.
- mean reversion (Mean Reversion): The tendency of a price or spread to drift back to its average after straying from normal.
- trading rule (Trading Rule): Entry, exit and stop-loss conditions fixed in advance that can be checked candle by candle, so they can be tested on historical data.