Building a Mechanical Trading System
Writing your trading down until there is nothing left to decide in the moment.
- Lesson
- 35
- Advanced level
- Reading time
- 8 min
- 3 chapters
- Practice
- 2
- quiz questions and 4 FAQs
A pilot does not decide in mid-air whether to check the fuel. There is a checklist, and it is followed every flight. The checklist exists because judgment is weakest when you are tired, excited or frightened.
A mechanical trading system is a checklist for the market. It is a set of written rules that says when to trade, how big to trade, where to exit, and what to record. If a rule cannot be written as a clear yes or no, it is left to judgment, and judgment is where mood enters.
This module explains how such a system is built and tested in simple steps, and what it cannot do. A written system removes some emotional mistakes, but it does not remove market risk, and it can fail when conditions change. Nothing here recommends any particular system.
Discretionary or rule-based: what is the difference?
A discretionary trader decides each trade by judgment: "the chart looks strong today". A rule-based (systematic) trader decides by a written rule: "buy only if the price closes above yesterday's high and the risk is within budget". The rule is the same every day, whatever the mood.
Rules have a clear benefit. After three losses in a row, a person may hesitate on a valid setup or force a poor one. A written rule does not care. Rules can also be tested on past data, which judgment cannot.
They also have costs. Rules cannot read a surprise that no rule anticipated, such as a sudden policy announcement. A system needs upkeep: someone has to notice when the market no longer behaves as the rules assume. Neither style is better for everyone. Many traders use rules for the parts where mood does the most damage, such as size and exits, and keep judgment for the rest.
Decision made by
Discretionary
Your judgment on the dayRule-based
A written ruleEffect of mood
Discretionary
HighRule-based
Lower, because rules are fixedCan be tested on old data
Discretionary
HardRule-based
Yes, with limitsHandles surprises
Discretionary
Can adaptRule-based
Only if a rule covers itMain weakness
Discretionary
Inconsistent, emotionalRule-based
Rigid; can decay when the market changes
| Feature | Discretionary | Rule-based |
|---|---|---|
| Decision made by | Your judgment on the day | A written rule |
| Effect of mood | High | Lower, because rules are fixed |
| Can be tested on old data | Hard | Yes, with limits |
| Handles surprises | Can adapt | Only if a rule covers it |
| Main weakness | Inconsistent, emotional | Rigid; can decay when the market changes |
Discretionary compared with Rule-based. Rules are revised from time to time.
Warning
What this does not tell you: that rules will make money. A rule-based approach with no edge simply loses money consistently.
What goes into a written rule set?
A useful rule set is like a recipe with quantities. Vague steps ("cook until done") give different results each time. The parts are these: a filter that decides if the day is tradable; an entry trigger; a position size calculated from your risk budget; a stop and target set at entry; an exit or roll rule; and a record of every trade.
Use price action for the triggers, that is, what price itself does: a close above a marked level, a break and retest of a range, a rejection from a level. Keep the trigger simple enough that two people reading it would mark the same trade. Add time rules too. For example, close single-stock option positions before the expiry week, because stock derivatives end in delivery and margin rises through the final sessions.
The flow below shows how the pieces link. The last steps matter as much as the first: the log, the weekly review and the rule-change step. Rules are edited only in the review, never in the middle of a live trade.
A rule-based trade: every step is written before the market opens
If a step cannot be written as a yes-or-no rule, it is judgment, and judgment is where mood enters.
What this does not tell you: A mechanical system removes in-the-moment mood, not market risk. Rules that worked in past data can stop working when conditions change, and too many rules can be over-fitted. Someone still has to review the rules on a fixed schedule, not in the middle of a trade.
Step by step
- 01
Define what you trade
For example, Nifty options only. A narrow list keeps you in liquid contracts.
- 02
Write the day filter
Conditions under which you do not trade, such as major event days.
- 03
Write the entry trigger
One or two price-action conditions that are clearly true or false.
- 04
Calculate size from risk
Use your risk budget and the loss per lot, rounded down.
- 05
Write the exits
Stop, target and a time exit, all fixed at entry.
- 06
Log every trade
Including whether you followed the rules.
Warning
When this goes wrong: adding rule after rule until the system only fits the past. More rules can make a test look better while making the live result worse.
How do I test rules without fooling myself?
A backtest applies your rules to old price data to see what would have happened. It gives figures such as number of trades, average win and loss, and the largest drawdown. It is useful for rejecting weak ideas. It is not proof that a good one will work.
The main danger is curve fitting. If you keep changing numbers until the past looks perfect, you have fitted the rules to that one history, and they will likely fail on new data. One protection is to split the data. You design and tune on the first block, then lock the rules and test once on a block you have not touched. If it fails there, you rethink the idea instead of tuning it to pass.
The last step is live testing with very small size. Live trading shows what data cannot: bid-ask spreads, slippage, brokerage, STT (raised for F&O from 1 April 2026) and your own behaviour. A system that looks good before costs can be a loser after them, and options with wide spreads suffer most.
Testing a rule set without fooling yourself
One common way to split history. The percentages are illustrations, not a standard.
What this does not tell you: A good backtest is not proof. Past data cannot include costs you did not model, slippage, changed rules, or a market that behaves differently next year. If you keep adjusting rules until the test looks good, you have fitted the past, not found an edge. Even a clean out-of-sample result can fail live.
Key points
- A backtest can reject a weak idea, but it cannot prove a good one.
- Lock the rules before the out-of-sample test, and look at that block once.
- Include real costs and spreads in every test.
- Start live with very small size and compare to the backtest.
Warning
What this does not tell you: whether the market will keep behaving as it did in the test period. A system that fits only one type of market can stop working when the type changes.
Common questions
Mechanical trading follows written rules for entries, size and exits. Discretionary trading relies on your judgment on the day. Each has strengths and weaknesses; many traders mix them.
Knowledge Check
Which is a good sign that a rule is clear enough for a system?
Keep reading
- Module 36Flawless Execution & Dual-JournalingOne journal for the numbers, one for the behaviour. Only the second one ever changes you.
- Module 34Mastering Emotional ControlFear, greed and revenge trading — the three that cost more money than any bad setup ever did.
- Module 30Defining Risk Per Trade & Stop-LossesDeciding what a single trade is allowed to cost you — before you place it, not while it is running.
Written By
Rohit Singh
Mr. Chartist
With 14+ years of experience in Indian financial markets, Rohit Singh (Mr. Chartist) is a SEBI Registered Research Analyst, Amazon #1 bestselling author, and the founder of Investology — a premium trading ecosystem trusted by a 1.5 Lakh+ strong community across India.
