algorithmic-trading · Lesson 3

From Strategy to Rules

How a fuzzy trading idea like 'buy the dip' becomes the precise, testable rules a computer can actually follow — one question at a time.

6 min readBeginnerSean ShaReviewed by Sean ShaUpdated: July 2026
From Strategy to Rules — illustration of a friendly kitchen scene where someone is translating a casual handwritten note

Educational purposes only. This content does not constitute investment advice. Read our disclaimer

StockCram is not a broker-dealer, investment adviser, or financial institution. All content is for educational and informational purposes only and should not be construed as personalized investment advice. Consult a qualified financial professional before making investment decisions. Past performance does not guarantee future results.

TL;DR

A computer can't act on 'buy the dip' — it needs every word pinned down. Turning a strategy into rules means answering five concrete questions: which assets (universe), the exact condition to open a trade (entry), the exact condition to close it (exit), how much to trade (position size), and when the system checks and acts (timing). Precision is what makes a strategy testable — able to be backtested and audited. It doesn't make the idea profitable; it just makes it checkable, and stops a human quietly overriding the plan.

A Computer Can't 'Buy the Dip'

Tell a friend to "buy the dip and sell the bounce" and they'll roughly know what you mean. Tell a computer the same thing and it just stares back. A machine has no common sense to fill in the blanks: it doesn't know which stocks count, how big a drop is a "dip," how much to buy, or when to look. In the last lesson we saw that strategy rules are box three of the algorithm — the part that turns an idea into an intended order. This lesson is about writing what goes inside that box.

The rule is simple and a little unforgiving: if a word in your strategy isn't defined, the computer can't use it. A vague idea doesn't just run poorly — it can't run at all, and worse, it can't be checked. Turning a strategy into rules is really the work of arguing with yourself until every fuzzy word has a number or a condition behind it.

The core translation

A strategy is a hunch in plain English. A rule set is that same hunch with every blank filled in — exact enough that a computer, following it literally, would place the same trades you pictured. The gap between the two is where most of the real work lives.

The Five Questions Every Rule Set Must Answer

However fancy or plain a strategy is, it isn't complete until it answers the same five questions. Miss one and there's a hole the computer can't cross:

From Strategy to Rules infographic: a vague trading idea like 'buy the dip' becomes precise, testable rules by answering five questions — universe, entry, exit, size, and timing — yet precision makes a strategy checkable, not profitable.
Turning a fuzzy trading idea into rules means pinning every blank to a number or true-or-false condition. That makes the strategy testable and auditable — but checkable is not the same as profitable.
  1. Universe — which assets? The menu the system is even allowed to touch. "Stocks" isn't enough; "the 100 largest U.S. stocks" is a list a computer can hold.
  2. Entry — the exact condition to open a trade. A precise trigger that's either true or false at any moment, with no judgment call in between.
  3. Exit — the exact condition(s) to close. Usually one or more of: a target (it reached the goal), a stop-loss (it fell too far), or a time limit (enough days passed). Something has to end every trade.
  4. Position size — how much? How many shares, or what slice of the account, goes into each trade. This is the dial that controls risk, and it's the one beginners most often leave blank.
  5. Timing / frequency — when does it check and act? Once a day after the close? Every minute? The answer decides how often the system even looks at its own rules.

Notice that none of these ask whether the idea is any good. They only ask whether it's fully specified. A brilliant strategy with a blank in it can't be run; a mediocre one that answers all five at least can be tested. Specification comes first.

Your Turn: Pin Down 'Buy Dips' Yourself

Now you play the pedant. We'll take the fuzziest idea there is — "buy stocks when they dip and sell when they bounce" — and drag it, one question at a time, into something a computer could actually follow. For each blank, spot the fuzzy word first, then pin it to a number or a true-or-false condition. (Every number below is illustrative only, picked to make the exercise readable — not a suggestion, and past behavior of any such rule wouldn't predict its future.)

The sentence you're about to specify

"Buy stocks when they dip and sell when they bounce." Read it once and it sounds finished. Read it the way a computer must and nearly every word is a hole: which stocks, how big a dip, how far a bounce, how much, and when to even look. Five blanks — let's fill them in, one step at a time.

1

Blank 1 — "stocks": which ones count?

"Stocks" feels obvious, but it isn't a list a machine can hold — there are thousands of them. Ask yourself: the system is allowed to touch which names, exactly? Pin it to something finite and checkable — the 100 largest U.S. stocks by market value. That's your universe; anything off the list can never be traded.

2

Blank 2 — "a dip": how far down, measured against what?

"When they dip" hides three questions at once: down from what, by how much, over what window? Collapse them into one condition that's simply true or false each day — price closes 5% or more below its 20-day moving average. No mood, no eyeballing, just a number the computer can check the same way every time.

3

Blank 3 — "a bounce": and what if it never comes?

"Sell when they bounce" quietly forgets the trade that just keeps sinking. Give the exit a goal and a backstop — price returns to the 20-day moving average, OR 10 trading days pass, whichever comes first. A target, a time limit, or a stop-loss: something has to end every trade so none can hang open forever.

4

Blank 4 — the word the idea forgot: how much?

Read the original sentence again — it never says how much to buy. Most vague ideas skip it. But a computer can't place "some" shares; it needs a size. Pin it — a fixed 2% of the account on each trade. This is the dial that controls risk, which is exactly why leaving it blank is the beginner's most expensive omission.

5

Blank 5 — the other forgotten word: when does it look?

The idea also never says when the system checks its own rules. Every minute? Once a day? You have to decide, because it sets how often the strategy even runs — check once per day, after the market closes. Fill that in and every blank is now closed.

Step back and look at what your five answers changed. "When they bounce" became two exact exits with a tie-breaker, so a trade can never hang open forever. "Stocks" became a fixed list. And the two blanks the original idea forgot entirely — size and timing — got answered, because the computer would have refused to trade without them. The idea didn't get smarter; it got complete.

Why 'Testable' Beats 'Clever'

Here's the payoff for all that pedantry. Because every rule is now exact, you can run it against years of past prices and see how it would have behaved — that's backtesting, the subject of the next few lessons. You can also audit it: two people reading the rules would place the identical trades, with nothing left to interpretation. A vague idea offers neither. "Buy when it's cheap" can't be backtested because no two runs would agree on what "cheap" means.

Precision ≠ profit

Pinning down every rule makes a strategy checkable, not profitable. A fully specified bad idea is still a bad idea — you can just now measure exactly how bad. Precision is the price of admission to testing; it isn't an edge on its own. Keep the two ideas separate and you'll avoid a trap that fools a lot of beginners.

The Ambiguity Trap

The sneakiest failure isn't a missing rule — it's a rule left half-vague on purpose. Say the entry reads "buy when it's oversold" without defining oversold. Now, every day, a human has to step in and decide what counts. And the moment a person is deciding in the moment again, all the emotion automation was meant to remove — the fear, the hope, the second-guessing — walks straight back in through that unlocked door.

That's why the goal isn't just "mostly defined." A rule with a soft spot invites the human to quietly override the system, and an overridden system isn't really automated — it's a person trading with extra steps. If you find yourself unable to pin a rule down to something true-or-false, that's usually a sign the idea itself is still too fuzzy to trust, not that the computer is being difficult.

Educational use only

Educational content only. StockCram isn't a broker or adviser, and we have no affiliation with any institution or tool we mention. Nothing here is a recommendation to trade in any particular way.

Key Takeaways

  • Computers need every word defined - A machine has no common sense to fill gaps. If a word in your strategy isn't pinned to a number or a true-or-false condition, the computer simply can't act on it.
  • Five questions complete any rule set - Universe (which assets), entry (when to open), exit (when to close), position size (how much), and timing (when it checks). Miss one and there's a hole the system can't cross.
  • Precision makes a strategy testable, not profitable - Exact rules can be backtested and audited; two people would place identical trades. But a fully specified bad idea is still bad — precision is the price of admission to testing, not an edge.
  • Ambiguity lets emotion back in - A rule left half-vague forces a human to decide in the moment, quietly overriding the system — which reintroduces the fear and hope that automation was meant to remove.

Continue Learning

Frequently Asked Questions

You answer five concrete questions until nothing is left to interpretation: which assets the system may trade (universe), the exact condition that opens a trade (entry), the exact condition that closes it (exit), how much goes into each trade (position size), and how often the system checks and acts (timing). Each answer has to be a number or a true-or-false condition — for example, 'price closes 5% below its 20-day moving average' rather than 'when it dips.'

An entry rule is the precise condition that opens a trade — a trigger that is either true or false at any moment, with no judgment call. An exit rule is the condition that closes it, and it's usually one or more of a target (it reached the goal), a stop-loss (it fell too far), or a time limit (enough days passed). Something has to end every trade, so a complete rule set always defines at least one exit.

A computer has no common sense to fill in missing details, so any undefined word — 'cheap,' 'oversold,' 'a dip' — simply can't be acted on. Precise definitions also make the strategy testable and auditable: two people reading the rules would place the identical trades, and the rules can be run against past data. A vague idea can be neither tested nor trusted.

No. Precision makes a strategy checkable, not profitable. A fully specified bad idea is still a bad idea — you can just now measure exactly how badly it would have behaved. Pinning down every rule is the price of admission to testing; any advantage still has to come from the underlying idea, not from the fact that it's written precisely.

A rule left half-vague forces a human to step in and decide what it means each time — and once a person is deciding in the moment again, the emotion automation was meant to remove comes back with them. An overridden system isn't really automated; it's a person trading with extra steps. Ambiguity is often a sign the idea itself is still too fuzzy to trust.

Share