17 May 2026 batch enrolling now — ₹5,000Register

Algo Trading

Algo Trading — Automate Your Edge

Build systematic trading strategies for NSE and BSE. Backtest, optimize, deploy.

Foundations

What is Algorithmic Trading?

Algorithmic trading — commonly called algo trading — is the practice of executing trade orders automatically using pre-programmed instructions based on defined criteria such as time, price, volume, or mathematical models derived from market data. Instead of a human deciding when to buy and when to sell, a computer program evaluates market conditions against a set of rules and fires orders directly into the exchange in milliseconds, without hesitation or emotion.

In the Indian context, SEBI governs API-based trading under its algorithmic trading circular. The key regulatory boundary for retail traders is this: you may use algos to trade your own account freely. However, if you manage funds on behalf of others or use an algo to generate trade signals for fee-paying clients, you must hold a SEBI-registered Investment Adviser (IA) or Research Analyst (RA) licence. Since 2018, the proliferation of broker APIs — particularly Zerodha's Kite Connect — has triggered an explosion in retail algo participation on NSE, turning what was once an institutional exclusive into an accessible discipline.

The distinction between retail and institutional algorithmic trading is important to understand. Institutional algos — at hedge funds, proprietary trading desks, and market makers — are often latency-sensitive High Frequency Trading (HFT) systems that compete on microsecond execution, co-location facilities, and raw technological infrastructure. Retail algos, by contrast, are strategy-based: they follow a defined set of rules to decide when to enter and exit positions over minutes, hours, or days. Retail traders actually hold a structural advantage that institutions cannot replicate: small position sizes. Because a retail trader's position is tiny relative to daily volume, they can enter and exit positions at or near the market price without moving the market against themselves.

The real value proposition of algo trading for a retail trader is discipline. A well-designed algorithm executes your strategy exactly as written, every single time, without second-guessing at 2:45 PM on a volatile Thursday. It removes the cognitive biases — loss aversion, recency bias, FOMO — that consistently erode discretionary trader performance. It allows you to backtest a strategy across years of historical data before risking a single rupee, and once deployed, it can monitor markets continuously while you focus on other work. For many retail participants, this represents a genuine and durable edge over purely discretionary trading.

Architecture

How an Algo Trading System Works

Market DataFeedNSE/BSE tick dataSignal EngineIndicators & triggersStrategy LogicRules & conditionsBroker APIZerodha / Dhan / FyersOrder ExecutionMarket / Limit ordersPosition ManagerP&L, MTM, stopsTrade LoggerAudit trail & review

Market Data Feed

Provides real-time tick data, OHLCV bars, and order-book depth from NSE/BSE. Can be streamed via broker WebSocket APIs or third-party data vendors. Data quality and latency here directly determines signal accuracy.

Signal Engine

Computes technical indicators (moving averages, RSI, ATR, VWAP) and evaluates conditions against each incoming tick or bar close. Emits a signal — buy, sell, or hold — to the strategy logic layer.

Strategy Logic

Applies higher-level rules: entry conditions, exit conditions, filters, and position limits. This is where your edge lives — the strategy logic enforces exactly when and how to act on a signal.

Broker API

The bridge between your code and the exchange. Zerodha Kite Connect, Dhan API, Fyers API, and Angel Smart API all expose REST endpoints and WebSocket streams for order placement, modification, and cancellation.

Order Execution

Translates strategy instructions into actual exchange orders — specifying order type (market, limit, SL-M), product type (MIS, CNC, NRML), quantity, and price. Good execution management includes retry logic and rejection handling.

Position Manager

Tracks open positions in real time, calculates mark-to-market P&L, applies stop-loss and target logic, and enforces portfolio-level exposure limits to prevent runaway risk.

Trade Logger

Records every order, fill, rejection, and signal event with timestamps to a database or log file. Critical for performance analysis, debugging, and maintaining an audit trail for tax and compliance purposes.

Strategy Library

Popular Algo Strategies

1

SMA / EMA Crossover

A fast-period moving average crosses above (bullish) or below (bearish) a slow-period moving average to generate buy and sell signals.

Works:Works well in sustained trending markets — strong trending phases in NIFTY or sector indices.
Fails:Whipsaws severely in choppy, sideways markets, generating many false signals and degrading returns.
Backtest:Always include at least one choppy year in your backtest window to get a realistic Sharpe ratio.
2

SuperTrend System

An ATR-adaptive trailing stop that flips from bullish to bearish based on price deviating beyond a multiple of the Average True Range.

Works:Excellent for intraday NIFTY 50 futures and Bank Nifty futures during directional sessions.
Fails:Underperforms during narrow range-bound days; generates quick stop-outs with low ATR multipliers.
Backtest:Backtest separately on trending days vs. inside-bar days; the aggregate win-rate often conceals a skewed distribution.
3

Mean Reversion (VWAP)

Price deviates above or below the Volume Weighted Average Price (VWAP) by a defined threshold and is expected to snap back.

Works:Most effective during normal intraday sessions on large-cap NSE stocks and NIFTY index futures.
Fails:Breaks down on strong news-driven or momentum days when price trends away from VWAP all day.
Backtest:Filter out earnings release days and macro event days when constructing your backtest universe.
4

Opening Range Breakout (ORB)

The high and low formed in the first 15–30 minutes of the trading session define a range. A breakout of this range with rising volume triggers an entry.

Works:Very effective on NSE equities and index futures on high-volatility days post news or gap opens.
Fails:Opening range is often violated and recaptured on range-bound days, resulting in false breakouts.
Backtest:Add a minimum ATR filter: only trade breakouts if the opening range width is at least 0.5× the 20-day ATR.
5

Momentum Strategy

Rank the NSE universe by 3–6 month price return (excluding the most recent month). Go long the top decile and review monthly.

Works:The momentum factor in Indian equities is well-documented academically with positive long-run excess returns.
Fails:Suffers sharp drawdowns during momentum crashes (sharp reversals in crowded momentum positions).
Backtest:Use a minimum 5-year backtest with monthly rebalancing. Include transaction costs and impact cost for accurate net returns.

Validation

Backtesting — The Foundation

Backtesting is the process of applying a trading strategy to historical market data to evaluate how it would have performed. It is the single most important tool in the systematic trader's arsenal — because it allows you to stress-test a strategy across years of market conditions, including bear markets, high-volatility regimes, and choppy sideways phases, before risking any real capital.

However, backtesting done poorly produces dangerously misleading results. The most common pitfall is overfitting — tuning too many parameters to fit historical data so precisely that the strategy captures noise rather than signal. An overfitted strategy may show exceptional historical returns and then fail immediately in live markets. As a rule of thumb, use fewer than five optimizable parameters for any strategy, and always validate that the logic makes economic sense.

Survivorship bias is another serious error: if you test a strategy only on stocks that are currently listed on NSE, you are implicitly excluding hundreds of companies that were delisted, merged, or went bankrupt over your test period. Your results will be optimistic by design. Use a full historical constituent list from a point-in-time database.

Lookahead bias occurs when your code inadvertently uses future information that would not have been available at the time of the trade — for example, using the day's closing price to decide whether to enter at the open of the same day. This is especially common with OHLCV bar calculations. Use a strict timestamp discipline in your backtesting framework.

What Makes a Backtest Credible

Minimum 3–5 Years of Data

Cover at least one full market cycle — a bull phase and a bear phase. Indian markets saw major drawdowns in 2020, 2022, and 2015–2016. Your strategy must have a defined response to each.

Realistic Transaction Costs

Include brokerage (₹20 flat or 0.03%), STT (0.025% on equity delivery sell, 0.0125% on intraday), exchange fees, GST on brokerage, and SEBI turnover charges. These compound significantly over hundreds of trades.

Slippage Modeling

Assume you cannot always fill at the exact signal price. Model a 1–3 tick adverse slippage on entry and exit, especially for liquid futures. For small-cap equities, use a percentage-of-spread slippage model.

Walk-Forward Analysis

Split your data into rolling in-sample windows for optimization and out-of-sample windows for validation. Consistent performance across multiple out-of-sample periods is far stronger evidence than a single backtest.

Out-of-Sample Testing

Reserve the most recent 12–18 months of data and do not touch it until your strategy is fully designed. Test on this holdout period once only — treat it as a live trading simulation.

Tools

Tech Stack for Indian Retail Algo Trading

Python Libraries

  • pandas — data manipulation & OHLCV processing
  • numpy — numerical computations
  • backtesting.py — simple event-driven backtester
  • vectorbt — vectorized backtesting, fast and visual
  • Jugaad-trader — NSE data scraper
  • OpenAlgo — broker-agnostic algo framework

Broker APIs

  • Zerodha Kite Connect — ₹2,000/month, most popular
  • Dhan API — free tier, good WebSocket support
  • Fyers API — free, good for options data
  • Angel Smart API — free, includes historical data
  • Upstox API v2 — REST + WebSocket, free

Signal Sources

  • TradingView webhooks — Pine Script → JSON alert → your server
  • Custom Python indicators — full control, no vendor dependency
  • NSE EOD data — free from NSE website
  • Tick-by-tick data — via broker WebSocket stream

Hosting & Infrastructure

  • AWS EC2 t2.micro — ~₹800/month, reliable Mumbai region
  • DigitalOcean Droplet — $6/month, beginner-friendly
  • Any Linux VPS — Bangalore/Mumbai DC preferred for latency
  • cron or APScheduler — task scheduling
  • systemd service — auto-restart on crash

Your Path

Getting Started Roadmap

  1. 1

    Learn Python Basics

    Variables, loops, conditionals, functions, and file I/O. Then move to pandas for data manipulation and matplotlib for chart plotting. Target: 4–6 weeks of self-study with free resources like Python.org docs and Real Python.

  2. 2

    Understand Trading Concepts

    Study how exchanges work, order types (market, limit, SL, SL-M), margin requirements, lot sizes, and basic price action. You cannot code a strategy you do not understand conceptually.

  3. 3

    Choose a Broker with API Access

    Open a demat + trading account with a broker that offers an API. Zerodha and Dhan are the best starting points. Subscribe to the API plan and read the official documentation thoroughly.

  4. 4

    Backtest a Simple Strategy

    Start with a single, well-understood strategy such as EMA crossover on NIFTY 50. Use backtesting.py or vectorbt on 3 years of daily OHLCV data. Review trade-by-trade results, not just the equity curve.

  5. 5

    Paper Trade for 30 Days

    Deploy the strategy in paper trading mode (most brokers support this) for at least one full calendar month. Track every signal, entry, and exit. Compare live signal results against your backtest expectations.

  6. 6

    Deploy with Tiny Capital

    Go live with the minimum viable position size — 1 lot of NIFTY futures or a single lot of liquid options. The goal is validating live execution, not making money. Run for 2–3 months before sizing up.

  7. 7

    Scale Gradually

    Increase position size only after consistent live performance matches backtest expectations across at least 100+ trades. Maintain a trading journal. Review monthly. Never size beyond your capital's ability to absorb a 10-trade losing streak.

Common Questions

Frequently Asked Questions

Is algo trading legal in India?

Yes. SEBI permits API-based algorithmic trading for your own account. You may not use algos to manage third-party funds without holding a SEBI-registered IA or RA licence. Most retail traders run algos entirely within their own demat + trading account, which is fully legal.

How much capital do I need to start algo trading?

You can start backtesting and paper trading with zero capital. For live deployment, ₹50,000–₹1 lakh lets you trade small position sizes to validate a live strategy. Meaningful monthly income typically requires ₹5–10 lakh or more depending on your strategy and risk-adjusted returns.

Do I need to know programming to do algo trading?

Python basics are sufficient for most retail algo strategies. You need to understand variables, loops, conditionals, and data manipulation using pandas and numpy. You do not need a formal computer science background — many successful retail algo traders are self-taught.

Can I run algo trading while working full-time?

Yes. Once a strategy is deployed on a cloud server (AWS, DigitalOcean, etc.), it runs autonomously during market hours, places orders via broker API, and logs trades — with no manual intervention required. You only need to review performance periodically and handle exceptions.

Which broker is best for algo trading in India?

Zerodha Kite Connect is the most widely used broker API with extensive documentation and a large developer community (₹2,000/month subscription). Dhan API is the most accessible for beginners with a free tier. Fyers API and Angel One Smart API are strong alternatives with good reliability.

Algo Trading Bootcamp — Coming Soon

Course in development. Join the wait list — message or call us on WhatsApp at +91 82484 88542 and we'll notify you when enrollment opens.