Entry, exit, sizing and filters as rules
Lesson 8 · about 10 min
A strategy is testable when two people, given the same data and the written rules, would produce the same list of trades. That standard is stricter than it sounds. "Buy pullbacks in an uptrend" fails it immediately: what is an uptrend, what is a pullback, where exactly is the order, and how much do you buy? This lesson breaks a strategy into its four components and shows what each looks like when it is written precisely enough to test.
The four components
| Component | Question it answers | Must specify |
|---|---|---|
| Filter | Are we allowed to trade right now? | Condition, evaluated on which bar, in which time zone |
| Entry | Exactly when and at what price do we get in? | Signal condition, order type, price, validity, what happens if unfilled |
| Exit | Exactly when and at what price do we get out? | Stop, target, time stop, trailing rule, and the order of precedence |
| Sizing | How much? | Formula from account, stop distance, and any caps |
Every one of these must be computable from data that existed at the time. If a component needs "judgement", it is not yet a rule.
Filters
Filters decide whether the entry rule is even considered. Regime filters (only long when price is above the 200-day average), volatility filters (skip when the 20-day ATR is below some level), time filters (no entries in the first 15 minutes, none on Fridays after noon) and event filters (no trades within one day of an earnings release) are the usual kinds.
Precise version: "Long entries are permitted on day D only if the close on D−1 is above the 200-day simple moving average of closes computed through D−1." Note the "through D−1": the filter uses only completed bars.
Entries
The entry rule has to name the order type, because the fill and the miss rate differ. Three precise forms of the same idea:
- "Buy at the open of D+1 if the close on D is above the highest close of the prior 20 days." Market order, always fills, pays the open.
- "Place a buy stop at the highest high of the prior 20 days plus one tick, valid for day D+1 only." Stop order; fills only if the level trades, fills with slippage.
- "Place a buy limit at the close of D minus 0.5 ATR, valid for D+1 only; cancel if not filled by the close." Limit order; better price, fills less often, and Module 4 covers the fill assumption you must make.
All three are the same "idea" with different trade lists. In the backtest they will show different win rates, average R and trade counts. Pick one and write it down.
Exits
Exits need a precedence rule, because on a single bar the stop and the target can both be touched. "If both the stop and the target are within the bar's range, assume the stop was hit first" is the conservative convention, and the one to use unless you have intrabar data that proves otherwise.
A complete exit block:
- Initial stop: entry price minus 2 × ATR(14) computed through the signal bar, placed as a stop order, held overnight.
- Target: entry plus 3 × the initial stop distance, placed as a limit order.
- Time stop: exit at the close of the tenth bar after entry if neither has filled.
- Precedence: on a bar where both stop and target are within the range, the stop fills.
- No discretionary exits.
Sizing
Sizing should be a formula, and the formula should reference the stop distance so that every trade risks the same fraction of the account. From the Risk Management course: shares = (account × risk fraction) ÷ (entry − stop). Add any caps: maximum position as a percent of account, maximum number of open positions, and maximum shares relative to the instrument's average volume.
| Field | Value |
|---|---|
| Account | $25,000 |
| Risk per trade | 1% = $250 |
| Entry | $42.00 |
| Stop | $40.40 (2 × ATR of $0.80) |
| Stop distance | $1.60 |
| Shares | 250 ÷ 1.60 = 156 |
| Position value | 156 × $42.00 = $6,552 (26% of account; under a 30% cap) |
The backtest should compute size this way on every trade so that R is consistent and the drawdown in R means something.
Key idea: A rule is a sentence with no adjectives that need interpreting. "Above the 20-day high" is a rule; "clearly breaking out" is not. If you cannot compute it from a column of numbers, you cannot test it.
The ambiguity test
Read each rule and ask "could this be read two ways?"
| Written | Ambiguity | Fixed |
|---|---|---|
| "Buy when RSI is oversold" | Which RSI length? What threshold? Cross or level? | "Buy at next open when RSI(14) on closes crosses from below 30 to above 30" |
| "Stop below support" | Where is support? | "Stop one tick below the lowest low of the 5 bars before entry" |
| "Take profit at resistance" | Same problem | "Limit at the highest high of the prior 20 bars" |
| "Don't trade in chop" | Undefined | "No entries when ATR(14) ÷ close is below 0.8%" |
| "Size normally" | Undefined | "1% of account ÷ stop distance, capped at 30% of account" |
Try it: Write your current strategy as a filter block, entry block, exit block and sizing block using only conditions computable from bar data. Hand it to another trader with a chart and ask them to mark the last five trades. If their trades differ from yours, the rules are not finished.
Recap
- A strategy is testable when two people would generate identical trade lists from the rules.
- Four blocks: filter, entry, exit, sizing. Each must be computable from past data only.
- Entries must name the order type; market, stop and limit versions of one idea are different strategies.
- Exits need a precedence rule for bars that touch both stop and target; assume the stop fills first.
- Sizing is a formula from account, risk fraction and stop distance, plus caps.
See it drawn
Original diagrams for the ideas on this page. Illustrative, not real market data.