Trading Rules
Trading rules are the fully specified, unambiguous logic (entry, exit, position sizing, timing and edge-case handling) that a backtest engine executes deterministically to turn a strategy idea into simulated trades.
Quick Answer
Trading rules translate a strategy idea into machine-executable logic: exact entry, exit, sizing and timing, with every edge case defined. Vague terms like oversold have no meaning to an engine. Timing is the danger zone — a Nifty signal computed on the daily close must fill at the next open, not that same close, or it embeds look-ahead bias.
Definition: Trading Rules
Trading Rules are the fully specified, unambiguous logic — entry, exit, sizing, timing and edge-case handling — that a backtest engine executes deterministically to turn a strategy idea into simulated trades.
Key takeaways: Trading Rules
- Trading rules are the strategy idea written precisely enough for a machine to execute
- Timing is the most error-prone part: act on the next available price, never the signal close
- Position sizing and order type are part of the rules, not afterthoughts
- Every parameter is a degree of freedom that raises overfitting risk
Trading Rules at a glance
| Defines | Entry, exit, sizing, timing, edge cases |
|---|---|
| Must be | Deterministic — same data yields same trades |
| Timing rule | Fill at next available price, never the signal close |
| Sizing | Part of the rules, not an afterthought |
| Order types | Market, limit or stop — each changes the fill |
| Failure mode | Undefined edge cases resolved silently by the engine |
| Overfitting risk | Each added parameter is a degree of freedom |
Trading Rules in simple words
Trading rules are your idea written so precisely that a computer can follow it with no judgement calls. They state exactly when to enter, how much to buy, when to exit, and crucially at which price and moment each order fills. Vague words like strong or oversold have no meaning to an engine, so every condition must become a concrete, testable statement.
What Trading Rules is for
This page explains how a strategy idea is translated into deterministic rules a backtest can execute, and why the timing of those rules is where most silent errors enter.
Trading Rules — professional explanation
Entry, exit and the full state machine
A complete rule set is effectively a state machine: it defines the conditions to open a position, the conditions to close it, and what happens in every intermediate state. Entries specify direction, trigger and price; exits specify profit targets, stop losses, time-based exits and trailing logic. Crucially the rules must resolve conflicts deterministically, such as what happens when an entry and exit signal coincide, or when a stop and target could both be hit within one bar. Any state the rules leave undefined becomes an implicit assumption the engine will resolve for you, often not the way you intended.
Position sizing is part of the rules
How much to trade is as consequential as when to trade, yet it is frequently left implicit. Sizing can be fixed quantity, fixed rupee value, volatility-scaled, or a fraction of equity, and each produces a materially different equity curve and drawdown profile from identical entry and exit signals. A strategy with a genuine directional edge can still be ruined by sizing that risks too much per trade. Because sizing interacts with compounding, two backtests of the same signals with different sizing rules are effectively two different strategies.
Timing and the next-bar rule
The most error-prone part of rule specification is timing. If a signal is computed from a bar's close, the order must be assumed to execute at the next available price, typically the next bar's open, never at the same close that produced the signal. Acting on the signal bar's own close is look-ahead bias, because in real time that close is only known once the bar has finished and the opportunity has passed. Every rule must answer precisely: at what moment is the decision made, and at what later moment and price is it filled.
Parameters, thresholds and their danger
Rules usually contain parameters: lookback lengths, threshold levels, stop distances. Each parameter is a degree of freedom that can be tuned, and every additional one increases the risk of overfitting to the tested history. Robust rule sets favour few parameters, values that make economic sense rather than ones discovered by exhaustive search, and thresholds that perform across a plateau of nearby values rather than at a single fragile point. A rule that only works at exactly one parameter setting has been fitted to noise.
Order types and execution assumptions embedded in rules
The rules must specify how orders reach the market: market, limit or stop, and what is assumed when a limit is not filled or a stop gaps through its level. A limit-order rule that assumes every limit fills ignores the reality that limits at good prices often go unfilled, which quietly overstates the edge. Conversely a market-order rule must account for slippage. The choice of order type is not an execution detail bolted on afterwards; it is part of the strategy definition and changes the achievable result.
Determinism, edge cases and reproducibility
For a backtest to be trustworthy, the rules must be fully deterministic: the same data must always produce the same trades. This means specifying behaviour for every edge case, such as insufficient capital, a gap through a stop, a trading halt, expiry, or a corporate action mid-position. Undefined edge cases are where subtle bugs and accidental hindsight hide. Writing rules as explicit, ordered conditions, and logging every decision, is what makes a backtest auditable rather than a black box.
Worked example: Trading Rules
Illustrative example (Indian market)
Consider a simple Nifty futures rule on Rs 5,00,000: go long one lot when the 20-day close crosses above the 50-day, exit when it crosses back below, no pyramiding. To make it executable you must add the missing decisions. The cross is detected on the daily close, so the order fills at the next day's open, not the signal close. One lot is 65 units (revised from 75 by NSE effective 28 Oct 2025, circular NSE/FAOP/70616), so with Nifty near 25,000 a lot is about Rs 16.25 lakh notional against Rs 5,00,000 margin, which fixes the leverage. You add Rs 20 brokerage and one tick of slippage per side. Only with the timing, sizing, order type and costs pinned down does the rule set become a real, reproducible backtest rather than a sketch.
On NSE, an intraday rule must also encode the square-off requirement and the fact that a stop can gap through its level on the open after overnight news, filling far worse than the stop price. Rules that assume the stop always fills exactly at its level understate real losses.
Advantages of Trading Rules
- Forces a vague idea into complete, testable logic
- Makes the strategy reproducible and auditable trade by trade
- Exposes hidden assumptions about timing, sizing and fills
- Enables systematic testing of robustness across parameters
Limitations of Trading Rules
- Every parameter added is a degree of freedom that invites overfitting
- Discretionary judgement cannot be captured without inserting hindsight
- Undefined edge cases become implicit assumptions the engine resolves silently
- Rules encode assumed fills that real liquidity may not honour
Why Trading Rules matters in practice
- The precision of the rules determines whether the backtest is honest
- Timing errors in the rules are the leading cause of look-ahead bias
How professionals treat Trading Rules
Professional systematisers write rules as explicit, ordered logic with every edge case defined and every decision logged, then keep the parameter count deliberately low. They separate signal generation from execution assumptions so each can be stressed independently, force all fills to the next available price, and treat position sizing as a first-class part of the strategy rather than an afterthought. The aim is a rule set another researcher could read and reproduce exactly.
Common mistakes with Trading Rules
- Acting on the signal bar's own close instead of the next available price
- Leaving position sizing implicit, so the equity curve is an accident
- Assuming every limit order fills at the desired price
- Adding parameters until the in-sample curve is perfect
- Not defining what happens when a stop and target could both hit in one bar
- Ignoring gaps, halts and expiries that occur while a position is open
Trading Rules: frequently asked questions
Why must rules be completely unambiguous?
Because a backtest engine cannot interpret vague terms like strong or oversold, and any state you leave undefined becomes an implicit assumption the engine resolves for you, often incorrectly. Unambiguous rules make the result reproducible and prevent hidden hindsight from creeping in.
Is position sizing part of the trading rules?
Yes, and it is as consequential as the entry and exit. Fixed-quantity, fixed-value, volatility-scaled and fraction-of-equity sizing produce materially different equity curves and drawdowns from identical signals, so two backtests of the same signals with different sizing are effectively different strategies.
Why is timing the most dangerous part of rules?
Because a small timing error, such as using the signal bar's close as the fill price, injects look-ahead bias that can turn a losing strategy into a winning one. Every rule must state precisely when the decision is made and at what later moment and price it is filled.
How do sizing rules interact with drawdown?
Sizing directly scales risk, so a strategy with a genuine edge can still suffer catastrophic drawdowns if it risks too much per trade. Because sizing interacts with compounding, the same signals can look smooth or violently volatile depending purely on the sizing rule chosen.
What edge cases should trading rules define?
At minimum: insufficient capital, a gap through a stop, a trading halt, expiry, coincident entry and exit signals, and corporate actions mid-position. Undefined edge cases are where subtle bugs and accidental hindsight hide, so specifying each keeps the backtest deterministic and auditable.
Do trading rules include the cost model?
Effectively yes, because the fill assumptions and order types the rules specify determine the frictions applied. A rule that assumes ideal fills with no slippage encodes an unrealistic cost model, so honest rules pair each order with a realistic brokerage, STT and slippage assumption.
Voice search: how people ask about Trading Rules
Natural-language questions people ask about Trading Rules.
What are trading rules in simple terms?
They are your strategy written so exactly that a computer can follow it, spelling out when to buy, how much, when to sell, and at what price each order fills.
Why can't I just say buy when it looks strong?
Because a computer cannot judge strong. Every condition has to become a concrete number or comparison it can test, or the backtest cannot run honestly.
When should my backtest fill an order?
At the next available price after the signal, usually the next bar's open. Filling at the same close that made the signal is cheating with hindsight.
Sources & references
- Pardo, R. (2008). The Evaluation and Optimization of Trading Strategies (2nd ed.). John Wiley & Sons.
- Chan, E. P. (2013). Algorithmic Trading: Winning Strategies and Their Rationale. John Wiley & Sons.
Published 11 July 2026. Educational content only — not investment advice. Markets and rules change; verify current conventions with SEBI, NSE/BSE and your broker.