Strategy Tools · Stocks

Stock Strategy Rule Builder

Define the rule before you test the strategy.

Turn a trading idea into a complete, auditable rule specification — universe, signals, entry, exits, sizing, and portfolio constraints — before you run a single backtest. Export as JSON or copy for your trading notes.

Why Specify Before You Backtest

Most backtesting failures happen before the first line of code: the strategy idea was never precisely stated. Without a written rule specification, it is impossible to know whether a backtest result reflects the idea you had in mind, an artifact of how you coded it, or a data-snooping accident discovered during "optimization."

This tool walks you through the nine components every rule-based strategy requires. Each section collects the decisions you would otherwise make implicitly — and implicitly re-make differently each time you revisit the idea. The output is a versioned, exportable document you can hand to a backtest engine, share with a collaborator, or attach to a trading journal entry.

All processing runs locally in your browser. Rule text and symbol names are never sent to analytics or any external service.

Strategy Rule Builder

This tool produces a specification document only. It does not validate logic, guarantee backtest accuracy, or constitute investment advice. All rule text remains in your browser.

1. Universe & Exclusions
Define which stocks are eligible for entry. Specifying the index as of signal date (not current constituents) avoids survivorship bias.
List any sub-sets of the universe you will never trade — by sector, price, liquidity threshold, or instrument type.
2. Timing
The bar resolution used when computing signal values. Mismatching signal and bar resolution is a common source of look-ahead bias.
When in the bar/session is the signal evaluated and the order decision made? Defining this prevents implicit lookahead from using within-bar prices to trigger on the same bar.
3. Entry Signal
State the entry condition precisely enough that two people reading it would compute the same set of qualifying stocks on the same date. Include indicator period, price reference (close/open/hl2), and all logical operators.
List any numeric thresholds or indicator parameters separately. This makes parameter sensitivity testing easier to document.
4. Entry & Order
Specifying the order type determines what fill price assumptions are realistic. Market orders assume immediate fill at the ask; limit orders may not fill at all.
Describe what price and conditions the backtest uses as the entry fill. Unrealistic fill assumptions are one of the most common causes of backtest-to-live divergence.
5. Exits
The loss-limiting exit. Required — a strategy without a defined stop has undefined maximum loss per position.
The gain-taking exit trigger, if any. Can be price-based, indicator-based, or a fixed return target.
A time-based exit prevents indefinite position holds when neither stop nor target triggers. Particularly important for mean-reversion strategies.
6. Position Sizing
Position sizing determines how many shares to buy. Fixed-R ties size to the stop distance so risk per trade is constant regardless of stock price or volatility.
State the specific numeric values used (account risk %, dollar amounts, R size). Include any per-position cap.
7. Portfolio Constraints
Without a position cap, a concentrated signal date can force an unrealistically large number of simultaneous entries in a backtest.
Limits exposure to a common risk factor — sector, market cap, or single name. Prevents a sector event from causing simultaneous stops across the whole book.
8. Event Policy
Earnings, FOMC decisions, and CPI releases cause volatility spikes that may trigger stops intraday. An explicit policy prevents ad hoc decisions during live trading.
List the specific event types this policy applies to.
9. Execution Costs
Half-spread cost in basis points. For liquid large-caps this is typically 1–5 bps. Enter 0 to assume no spread cost in the backtest (optimistic).
Per-share commission. Many retail brokers charge $0 commissions but route through payment-for-order-flow venues that widen the effective spread.

Intended Use and Limitations

The Stock Strategy Rule Builder produces a documentation artifact. It does not validate the logical correctness of your rules, verify that the described signals can be computed from available data, or evaluate whether your strategy has positive expected value. A complete rule specification is a necessary precondition for a credible backtest — it is not a substitute for one.

Nothing produced by this tool constitutes investment advice, a trading recommendation, or a guarantee of future performance. The purpose of the research checklist is to surface the most common gaps between a written specification and a production-ready strategy — it is not exhaustive. All trading involves risk of loss.

Related Reading