⚠ Trading involves significant risk of loss. Everything on this site is for education only and is not financial advice.
Lesson 2 of 12 · Free

Turning an idea into precise, testable rules

Translate a trading idea into a written hypothesis and an unambiguous rule set that a spreadsheet can test.

Author: Moustafa HijaziContent reviewed: 2026-10-305 min readSelf-study course

What you will learn

  • How to write a trading idea as a hypothesis with a reason behind it.
  • A rule template that covers every decision, including ties and missing data.
  • How to time signals and orders so that no future information is used.
  • How to count the free parameters in a rule set.

Explanation

The basic yes/no test for rules was covered in the course "Technical Analysis in Depth". Here you write a full specification: a document so complete that two people who never talk to each other would produce the same list of trades from the same data.

Step 1: the hypothesis

A hypothesis is a testable statement about market behaviour plus a reason. Example: "Broad equity indices that are above their long-term average tend to keep rising more often than not, because trends in investor flows and economic news persist for months." The reason matters: it tells you what should not work if the idea is true, and it protects you from testing random patterns.

Step 2: the rule template

Fill in every line. "Not needed" is an allowed answer; an empty line is not.

Block Questions to answer
Universe Which instruments? Which list on which date?
Data Which bar (daily, monthly)? Which price (close, adjusted close)? Which source?
Signal Exact formula, including the lookback length.
Schedule When is the signal checked? What if that day is a holiday?
Entry Order type and price: next open, next close, limit?
Exit Signal exit, stop, time limit? Which one wins if two happen together?
Sizing Fixed amount, fixed fraction or risk-based?
Edge cases Ties (value exactly equal), missing data, several signals at once.

Step 3: timing without looking ahead

Look-ahead bias means using information that was not yet known at the decision time. The safest timing convention is: calculate the signal with data up to the close of bar t, and trade at the open (or close) of bar t+1. A rule such as "buy at today's close if today's close is above the average" is technically possible only if you can place the order in the last seconds of trading; most backtests should not assume that.

Step 4: count the parameters

A parameter is any number you could change: lookback lengths, thresholds, stop distances, check days. Write them in a list. Each extra parameter gives the test another way to fit past noise (lesson 6). A useful habit is to fix parameters from the hypothesis before looking at any results, for example "about one year, so 10 to 12 months".

Vague words to replace

  • "Strong", "weak", "oversold" → a number and a formula.
  • "Breaks out" → close above the highest close of the last N bars, by how much, on which bar.
  • "Usually" or "if it looks good" → remove; a rule cannot contain judgement.

Worked example

Hypothetical example: the idea above becomes this specification.

  • Universe: one broad equity index ETF. Data: monthly closes, adjusted for distributions.
  • Signal: 10-month simple moving average (SMA), the average of the last 10 monthly closes including the current one.
  • Schedule: last trading day of each month, after the close.
  • Rule: if close > SMA, hold the ETF next month; if close < SMA, hold cash. If close = SMA exactly, keep the current state.
  • Entry/exit: at the open of the first trading day of the next month. Sizing: 100% of the account. Parameters: 1 (the length 10).

Hypothetical closes for months 1–10: €100, €102, €99, €104, €107, €105, €110, €108, €112, €113.

  • Sum = €1,060. SMA = €1,060 ÷ 10 = €106.00.
  • Close €113 > €106.00 → buy at the next month's open.

Month 11 closes at €103. The new window is months 2–11: €1,060 − €100 + €103 = €1,063. SMA = €106.30. Close €103 < €106.30 → sell at the open of month 12. Costs, spreads and taxes are excluded here.

Common mistake

Leaving decisions to "common sense"If the rules do not say what happens on a holiday, on a tie or when data are missing, the person running the test decides on the spot, often in the direction that improves the result. Write every edge case down before the first test.

Practice activity

Rewrite this vague idea as a complete rule set on paper: "Buy a stock index when it is oversold in an uptrend and sell when it has recovered." Use the template above and count your parameters.

Show solution

One possible answer (many are valid if they are complete):

  • Universe: one broad equity index ETF. Data: daily adjusted closes.
  • Uptrend: close above its 200-day SMA. Oversold: 2-day RSI (Relative Strength Index) below 10.
  • Schedule: check after every daily close.
  • Entry: if both conditions are true and no position is open, buy at the next day's open.
  • Exit: sell at the next open after the close rises above the 5-day SMA, or after 10 trading days, whichever comes first. If both happen on the same day, exit once.
  • Ties: "below 10" means strictly below; equal values do not trigger. Missing data: no signal that day.
  • Sizing: 100% of the account, one position at a time.
  • Parameters: 200, 2, 10, 5, 10 → five parameters.

Limitations: five parameters is already a lot for one idea; lesson 6 shows how to check whether they are fitted to noise.

Key takeaways

  • Start with a hypothesis and a reason, not with a pattern found on a chart.
  • A complete specification lets two people produce identical trades from the same data.
  • Calculate signals on bar t and trade on bar t+1 to avoid look-ahead bias.
  • List every parameter and fix it before you see any results.

Next step

In the next lesson you will check the data that your rules depend on, because a perfect rule set tested on flawed data still gives misleading results.

Self-check

Answer the questions, then check your answers. You can retry as often as you like.

1. A rule says: "If today's close is above the 50-day average, buy at today's open." What is the problem?

2. Hypothetical example: a 4-month SMA rule. The last four monthly closes are €50, €52, €49 and €53. What does the rule say if it holds when the close is above the SMA?

3. Which addition makes a rule set most complete?

Automatic self-check for your own revision. Your answers are checked in your browser and are not seen or assessed by us. It is not an exam and not a qualification.

Your progress

“Complete” only means you marked the lesson as done. It is not a test of your understanding. Progress and notes are saved only in this browser on this device — not in an account.