Skip to content

Automation

Algorithmic trading explained: how rule-based trading works

Algorithmic trading means writing a trading idea as exact rules and letting software apply them. The software can watch data, generate signals and, where permitted, send orders through a broker. Automation makes behaviour consistent; it does not make a weak idea profitable.

Key points

  • An algorithm is only as good as its rules, its data and the way its orders are handled.
  • A complete system has five parts: data, signal logic, risk and sizing, execution and monitoring.
  • In India, retail algorithmic orders flow through SEBI-registered brokers under a framework that exchanges and brokers implement in phases.
  • Automation adds technology risks such as bad data, outages, duplicate orders and runaway loops.

What counts as algorithmic trading

Any process where a computer decides when to place, modify or cancel an order according to predefined rules is algorithmic trading. That ranges from an institution's execution algorithm that splits a large order into small pieces to a retail trader's rule such as 'buy when the 20-period moving average crosses above the 50-period average, with a stop at twice the ATR'.

The defining feature is precision. A human can say 'the trend looks strong'; an algorithm must state which data, which timeframe, which calculation and which threshold define a strong trend. Writing those rules down is valuable even if you never automate them, because vague rules cannot be tested.

Algorithms are not a separate asset class or a source of edge by themselves. The same market risks apply: prices gap, liquidity disappears, and a rule that worked historically can stop working. The risk management guide applies to automated and manual trading alike.

The five parts of a trading system

Components of an automated trading system
ComponentWhat it doesTypical failure
Market dataSupplies prices, volumes and timestampsMissing bars, late ticks, wrong session times
Signal logicTurns data into entry and exit decisionsAmbiguous rules, look-ahead bias, repainting
Risk and sizingDecides quantity and loss limitsStops ignored, size too large for the account
ExecutionSends orders to a broker and tracks their stateRejections, partial fills, duplicate orders
MonitoringRecords what happened and alerts on problemsSilent failures nobody notices

Beginners tend to spend almost all their time on signal logic. In practice, most operational losses in automated trading come from the other four parts: a stale data feed, a quantity bug, an order that was sent twice, or a stop that existed in the plan but never at the broker.

Signals versus execution prices

A signal is a decision computed from data; an execution is what the market actually gave you. They differ because of slippage, the bid-ask spread, latency and partial fills. Some strategies calculate signals on transformed candles such as Heikin-Ashi, whose values are averages and are not prices you can trade at.

Algorithmic trading for retail investors in India

SEBI, India's securities market regulator, has issued a framework for safer participation of retail investors in algorithmic trading. In broad terms it allows retail investors to use algorithms through their registered stockbroker's API, requires algorithmic orders to be identifiable to the exchange, places responsibility on brokers for the algorithms and API access they offer, and distinguishes simple self-built algorithms from those offered by third-party providers, which need exchange registration through the broker.

Exchanges and brokers implement this framework in phases, and details such as registration thresholds and technical controls can change. If you use or build an algorithm, confirm the current requirements with your broker and the exchange circulars rather than relying on any summary, including this one.

  • Orders still go through a SEBI-registered broker; no third party should ask for your broker password.
  • API access is typically tied to your own account and may be restricted by static IP, session tokens or rate limits.
  • Tools that sell ready-made strategies to retail users may need to be registered via a broker with the exchange.

Technology risks unique to automation

A manual trader who makes a mistake usually makes it once. A program can repeat it many times per second. Well-built systems include defensive controls that sit outside the strategy logic itself.

  • Maximum order quantity and maximum value per order.
  • A daily loss limit that stops new entries once reached.
  • Duplicate-order protection, usually a unique client order identifier per intended order.
  • Stale-data checks that refuse to trade when the latest bar is too old.
  • A manual stop that halts new entries without needing the strategy to cooperate.

Note that 'stop new entries' is not the same as 'cancel all orders' or 'close all positions'. A good system documents exactly what each control does.

A sensible learning path

  1. Write the idea as rules: see strategy development.
  2. Test it on history while avoiding common biases: see backtesting.
  3. Run it forward on paper so you meet real data issues: see paper versus live trading.
  4. Understand how orders reach a broker: see broker connectivity.
  5. Only then consider small, controlled real-money exposure you can afford to lose.

Frequently asked questions

Is algorithmic trading legal for retail investors in India?

Yes, through a SEBI-registered stockbroker's API under SEBI's framework for retail algorithmic trading. Requirements such as algo identification and registration of provider algorithms are implemented by exchanges and brokers, so check current rules with your broker.

Does an algorithm remove emotion from trading?

It removes some in-the-moment decisions, but people still choose the rules, override the system, and change parameters after losses. Behavioural discipline remains important.

Can AlgoStok run my algorithm with real money?

No. Live order placement is disabled on AlgoStok. Strategy signals and paper workflows are available in configured environments.