← All writing

How a Software Engineer Builds a Trading System (Not a Strategy — a System)

  • software
  • systems-thinking
  • engineering
  • trading

When I first started trading seriously, I made the same mistake every retail trader in India makes: I went looking for the strategy. The right indicator combo. The secret pattern. The setup that “always works.”

It didn’t help that every Telegram group, every “F&O karke crorepati bano” YouTube channel, and every “Profit ka raja” Twitter handle was offering me one. Three hundred rupees a month and they’d send you the holy grail setup. Bilkul guaranteed, sir.

It took me embarrassingly long to notice that strategy is the smallest, easiest, most copy-pasteable part of trading. Anyone can describe a strategy in two lines: “Buy when price retests this zone after a sweep, stop below the sweep, target the next liquidity pool.” You can find a hundred such setups on YouTube tonight — half of them in Hindi, all of them confident, none of them honest about their losers.

What separates a trader from someone using a strategy is the system around it — the spec, the constraints, the rules of engagement. That’s the part nobody on YouTube shows you, because it’s not exciting. It’s just boring, well-defined engineering.

Here’s how I think about it now, as someone who spends his day job designing APIs.

A trading system has four contracts, not one

In software, when you build a service, you don’t just write the happy-path logic. You define:

  • What inputs it accepts (and rejects)
  • What its dependencies are
  • What its failure modes look like
  • How it gets invoked

A trading system needs exactly the same four things. I write them on the first page of every new strategy I test:

1. Market Condition (the input contract)

A strategy isn’t valid in every market. It’s valid in specific conditions. So before anything else, I write down: under what regime does this setup actually work?

For a trend pullback setup: I need a clear higher-timeframe trend, with price respecting structure, and a discount/premium zone forming on the lower timeframe.

For a liquidity sweep reversal: I need obvious resting liquidity (equal highs or lows), an aggressive sweep, and a clean market structure shift on the LTF.

If the market doesn’t meet the condition, the strategy doesn’t get invoked. It’s not “chalo dekhte hain, kya pata chal jaaye.” It’s a guard clause. Return early. Wait.

This single discipline — only trading when the regime matches — does more for P&L than any new indicator ever has.

2. Entry Setup (the function signature)

Once the market qualifies, the setup itself needs to be precisely specified: Entry, Stop Loss, Risk, Exit. Four fields. No ambiguity.

If I can’t articulate all four in writing before I click the button, the trade isn’t real. It’s a feeling wearing a trade’s clothes.

I currently work with three setups I’m validating:

  • Trend Pullback — clean trend, pull into discount/premium, entry on LTF confirmation
  • Liquidity Sweep Reversal — sweep of obvious liquidity, market structure shift, retrace entry
  • Breakout + Retest — MSS plus a retest of the OB or FVG that caused it

That’s it. Three. Not thirty. Most beginner traders fail not because their setups are bad, but because they have too many and switch between them constantly — which means they never accumulate enough data on any single one to know if it actually works.

Three is a manageable surface area. I can study three setups deeply. I cannot study thirty.

3. Risk Management (the safety layer)

This is the part nobody wants to talk about because it’s not the fun part. It’s also the only part that determines whether you survive long enough for the fun part to matter.

My rules:

  • 0.5% account risk per trade. Fixed. Not adjustable based on conviction. Conviction is the most expensive feeling a trader can have.
  • Pre-defined SL and TP, written down before entry. If the trade isn’t pre-planned, the trade doesn’t happen.
  • Break-even or close when in profit before TP. Once the trade is moving, the goal shifts from making money to protecting what’s already there.

The thing I tell myself every morning before 9:15: protection first, then opportunity. When I’m not well prepared for a session — slept badly, fought with someone, drained from work — the answer isn’t “trade more carefully”; it’s trade less, or not at all. Capital preserved on a bad day is capital available on a good day. That’s it. That’s the whole game.

4. Execution Rules (the operational layer)

Even with a good setup and good risk, you can blow up by violating operational rules. So I keep a short, brutal list:

  • Max 2 trades per day (for the next 3 months, while I’m building consistency)
  • Max daily loss = 1R. If I’m down a full R on the day, I’m done. The market doesn’t owe me a comeback. The NSE doesn’t care that you “feel” something is about to move.
  • When NOT to trade: during news (RBI policy, Fed, US CPI, India CPI), after a loss when I’m emotional, when I haven’t done pre-market prep, when the regime doesn’t match any of my three setups.

These rules exist because willpower is a finite resource. Every rule I write down is one decision I don’t have to make in the heat of the moment. The rule has already made it for me.

The pre-market ritual

Before any of the above can run, the system needs a startup sequence. Mine looks like this:

  1. Neutral mindset. Anything can happen. I’m not predicting; I’m reacting to high-probability setups.
  2. Clear everything from the chart. Start fresh. No leftover bias from yesterday.
  3. Top-down analysis with PD arrays plotted (premium/discount, OBs, FVGs, liquidity pools).
  4. Develop a trade plan based on HTF structure. Mark anticipated POIs before the market opens. Decide what setup, in what zone, with what invalidation.

This is the moral equivalent of writing the test before the code. By the time the market opens at 9:15, the decisions are mostly made. Execution becomes mechanical — which is exactly what you want.

What this actually buys you

When I structure trading this way, the day stops being about prediction and starts being about execution. I’m no longer asking “will price go up?” I’m asking “is one of my three pre-defined setups printing in the zone I marked this morning, with risk I pre-defined, and have I already taken my two trades for the day?”

That’s a system. The strategy lives inside it.

The dirty secret nobody told me when I started: putting on a winning trade requires no skill at all. Anyone can press buy and get lucky. Boss, even my cousin made money on a Nifty long in the 2021 bull run, and his strategy was “bhai bull market hai, kuch bhi le lo.”

Producing consistent results over months — that’s the skill, and it lives entirely in the system around the trade, not in the trade itself.

What I’d tell my earlier self

If I could send one message to the version of me who was burning hours hunting for the perfect indicator: stop looking for a better strategy. The strategy isn’t your problem.

Your problem is that you’re trying to run an unspecified function with no input validation, no error handling, no rate limiting, and no monitoring. Of course it crashes in production. It would crash in production no matter what algorithm you wrote inside it.

Define the contracts first. The strategy fits inside them. That’s the work.