AI trading desk for Indian markets
Algo Trading

How to Write a Clear Rule-Based Trading Strategy

Learn how to turn a trading idea into clear entry, exit, sizing, and risk rules that a person or an algo can follow the same way every time.

A
Anadi Algo Research
Jul 1, 2026  ·  6 min read
How to Write a Clear Rule-Based Trading Strategy editorial illustration

Most traders can describe their strategy in a sentence. "I buy the breakout and sell when it reverses." The problem starts when you try to trade that sentence tomorrow, or hand it to an algo. What is a breakout? Which reversal? How much do you buy? A rule you can't repeat isn't a rule — it's a feeling.

This guide shows you how to write entry, exit, sizing, and risk rules that a person or a machine can follow the same way every single time.

A good rule is testable, not just readable

A rule is only useful if two people reading it would place the same trade. That's the test. If your rule needs your interpretation in the moment, it will drift with your mood.

Three quick checks for any rule you write:

  • Can it be true or false at a specific price and time? ("NIFTY above 20-EMA on the 15-minute chart" passes. "NIFTY looks strong" fails.)
  • Does it name the exact instrument, timeframe, and level?
  • Could an algo evaluate it without asking you a question?

If a rule fails any of these, it isn't finished.

The four blocks of a complete strategy

Struggling traders obsess over the entry and ignore everything else. But the entry is the smallest part of the edge. A complete strategy has four written blocks:

  • Entry — the exact condition that opens a trade
  • Exit — separate rules for the loser and the winner
  • Sizing — how many lots or shares, decided before you click
  • Risk — the limits that decide whether you keep trading at all

Skip any one and the other three can't save you.

Entry rules: kill the ambiguous words

Every strategy has a few dangerous words that feel precise but aren't. "Breakout," "strong," "oversold," "near support." Each one hides a decision you haven't made yet.

Take "breakout." On a scanner it could mean a 20-day high, a move above yesterday's high, or a named chart pattern like a trendline breakout. Those are three different trades. This is why a good scanner preserves exact pattern IDs like trendline_breakout_up instead of flattening everything into "new high" — the name is the rule.

Rewrite each vague word as a condition:

  • "Oversold" → "RSI(14) under 30 on the daily chart"
  • "Above support" → "close above the 50-day moving average"
  • "Breakout" → "15-minute close above the trendline breakout signal from the scanner"

Add the context filters

A clean entry usually has a trigger plus a filter. The trigger fires the trade; the filter decides when you're allowed to take it. Example: only take long breakouts when NIFTY is above its 50-EMA, or only sell options when India VIX is under a level you've set. Write the filter as its own line so you can turn it on and off during testing.

Exit rules: define the loser and the winner separately

Most people write one exit and call it done. You need two, because losing trades and winning trades leave for different reasons.

Stop-loss (the loser): the price where your idea is proven wrong. Anchor it to structure, not to a round rupee figure — below the swing low, above the pattern's invalidation level, or a fixed number of points. Obvious levels get hunted, so decide whether your stop sits at the level or beyond it, and write that choice down.

Target or trail (the winner): decide in advance how you bank profit. A fixed risk-reward like 1:2, a trailing stop under each higher low, or a time-based exit like square off before 3:15 pm on an intraday trade.

Also write a "nothing happens" exit. If a trade neither hits the stop nor the target by a set time, what do you do? Undefined trades become overnight risk by accident.

Position sizing: decide the size before the trade

Sizing is where discipline actually lives. The rule is simple: fix the rupee risk per trade first, then let that decide the quantity.

Example: capital ₹5,00,000, risk 1% = ₹5,000 per trade. If your stop is 25 points away on a NIFTY position where each point is ₹75 for one lot, one lot risks ₹1,875, so you can take up to two lots and stay inside the limit. The math sets the size — not how confident you feel.

Never size up because a setup "looks better." Confidence is not a number, and your rules only work with numbers.

Risk rules: the layer that keeps you in the game

Entries decide when you trade. Exits decide how you leave. Risk rules decide whether you're still trading next month.

Write hard limits that sit above every individual trade:

  • Max risk per trade (for example, 1% of capital)
  • Daily loss limit — stop for the day after losing a set amount
  • Max open positions or total exposure at once
  • A rule for correlated trades (three BANKNIFTY longs is really one big trade)

These aren't suggestions you follow when you feel like it. Put them in writing and, ideally, into a system that enforces them. A dedicated risk management layer exists for exactly this reason.

From idea to written rules: a worked example

Start: "Buy NIFTY on a breakout with a stop and a target."

Finished:

  • Universe: NIFTY spot / futures
  • Entry trigger: 15-minute close above the scanner's trendline_breakout_up signal
  • Filter: NIFTY above its 50-EMA on the daily chart
  • Stop-loss: 30 points below entry
  • Target: 1:2 risk-reward (60 points)
  • Time exit: square off by 3:15 pm
  • Sizing: 1% capital risk per trade
  • Daily limit: stop after two losing trades

Now anyone — you, a teammate, or an algo — can execute it identically. This is exactly the jump a strategy builder is meant to make: you describe the idea in plain language, and it forces every blank to be filled before the strategy can be saved or tested.

Test before you trust

Written rules aren't proven rules. Once the blocks are explicit, run them against history to see how they behaved across different markets, not just the last good week. A rule set that only works in a trending month will hurt you in a range. Backtest first, then forward-test on paper, then risk small. Solid options backtesting covers that first step.

Your rule-writing checklist

Before you trade any strategy, confirm every line is written and testable:

  • Entry trigger names instrument, timeframe, and exact condition
  • Every vague word replaced by a measurable value
  • Filter conditions written separately
  • Stop-loss anchored to structure, in points or a level
  • Winner exit defined (target, trail, or time)
  • A "nothing happens" time exit
  • Position size derived from fixed rupee risk
  • Daily loss limit and max exposure set
  • The whole thing backtested, then paper-traded

If you can tick all nine, you have a strategy. If you can't, you have an idea that still needs writing down.

Ready to turn your idea into rules a machine can follow the same way every time? Get early access to Anadi Algo and build your first rule-based workflow without writing code.

Related

Strategy Builder

Build rule-based workflows without turning every idea into custom code.

Explore →