Skip to content
72lab
Strategy & Backtesting· Lesson 3 of 7· 6 min

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.

This lesson is free: sign up for an account to use the interactive simulation

Every lesson has an interactive simulation you can drag and play, plus a quick quiz. Sign up free to use them and save your progress automatically. Here is the text version of this lesson.

Not sure yet? Try the first lesson (no sign-up needed)「Lag and False Signals」。

Text version · Strategy & Backtesting, lesson 3: “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.
  • Start with the simplest rule you can build from two or three blocks; the more complex a rule, the more likely it's just fitting the past (the last lesson of this course covers overfitting).

Try it yourself

You can do these exercises in this lesson's interactive simulation:

  1. In “Steady uptrend”, use “Price × MA” (20-day): what are the rule's return and buy and hold's return? And the maximum drawdown?
  2. Keep the same rule and switch to “Sideways range”: how many trades did it make? What's the rule's return?
  3. In “Sideways range”, switch to the RSI block (default 7-day, 30 / 70): what's the return now? And back in “Steady uptrend”?
  4. 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?
2. What kind of market hurts a mean-reversion rule like RSI 30 / 70 the 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?
3 questions left to answer. Answers and explanations appear after you submit.

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.