HomeFinance Basics
Basics of Algorithmic Trading: A Practical Guide

Basics of Algorithmic Trading: A Practical Guide

A trading idea can sound simple: enter when a price breaks above a range, exit when the setup fails, and keep the position within a fixed limit. Following that idea consistently takes more work. We need to watch the right data, calculate quantities and track what happens after each order. Algorithmic trading puts those instructions…

Basics of Algorithmic Trading: A Practical Guide

A trading idea can sound simple: enter when a price breaks above a range, exit when the setup fails, and keep the position within a fixed limit. Following that idea consistently takes more work. We need to watch the right data, calculate quantities and track what happens after each order.

Algorithmic trading puts those instructions into software. It gives us a way to turn a trading plan into repeatable actions, while leaving us responsible for the plan, its limits and its results.

In this guide, we’ll work through the basics of algorithmic trading, explore common approaches and see what needs attention before a system reaches a live market.

What is Algorithmic Trading?

Algorithmic trading uses computer programs to generate, submit or manage trading orders according to defined rules. Those rules may depend on price, volume, time, market conditions or a mathematical model.

For example, we might write a rule that checks a stock’s price at the end of each five-minute interval. If a specified condition is met, the program checks the position limit before sending an order.

The word “algorithm” simply means a sequence of instructions. It does not mean the system uses artificial intelligence, predicts prices correctly or earns a profit.

We also need to separate a signal from an executed trade. A signal says our conditions have been met. An order asks the market to buy or sell. A fill confirms that some or all of the requested quantity has actually traded. A sound system keeps track of all three.

How Algorithmic Trading Works: a Simple Example

Let’s build a hypothetical breakout example using a fictional stock, ABC. The numbers explain the workflow; they are not a trading recommendation or a tested strategy.

Suppose ABC’s highest price during a defined morning period is ₹500. We want to study what happens when a later five-minute candle closes above that level. A candle summarises price activity over a set interval.

Our example needs more detail than “buy above ₹500”:

  1. Entry condition: A completed five-minute candle closes above ₹500 after the reference period ends.
  2. Position condition: We hold no ABC shares and have no pending ABC entry order.
  3. Order instruction: Request 20 shares with a buy limit of ₹501, subject to funds and trading permissions.
  4. Unfilled-order rule: Request cancellation of any unfilled quantity after a defined timeout and check the final status.
  5. Exit condition: For shares actually bought, monitor a hypothetical ₹495 exit trigger and a defined end-of-session exit time.

A limit order sets the highest price we are willing to pay. It does not ensure the order will fill. If the market moves above ₹501, the entry may remain unfilled. If only eight shares trade, our system must manage eight shares, not the 20 originally requested.

Assume all 20 shares are bought at ₹501 and later sold at ₹495. The price loss is ₹120: 20 × ₹6. Charges would add to that loss. If the market moves sharply, the exit may occur below the trigger, making the loss larger.

We cannot treat the exit trigger as a guaranteed selling price. We also need rules for rejected orders, delayed updates and cancellation requests that arrive after an order has filled.

This is where an apparently simple idea becomes a complete trading workflow. Entry logic matters, but position records and order handling determine whether the software does what we intended.

Basics of Algorithmic Trading

Common Algorithmic Trading Strategies

We can group algorithms by what they are trying to achieve. Some identify potential trades. Others focus on carrying out an order that has already been decided.

Trend-Following Strategies

Trend-following systems look for evidence that a price movement is continuing. A moving average, which averages prices over a chosen period, can help define that movement. Breakouts above or below a specified range are another approach.

For a hypothetical rule, we could compare a shorter moving average with a longer one. A crossover becomes an entry or exit signal only after we specify the calculation, timing and position rules.

When prices move sideways, repeated reversals can trigger several losing trades. We therefore need to study both sustained trends and choppy periods, rather than judge the rule by one strong market move.

Mean-Reversion Strategies

Mean reversion starts with the hypothesis that a price, or a relationship between prices, may return towards a reference level after moving away from it.

We might measure how far a price has moved from its recent average and test whether that distance tends to narrow. The reference period and entry threshold must be defined before testing.

A falling price can keep falling. An unusual move may reflect new information rather than a temporary deviation. Our rules need a way to limit exposure when the expected return towards the average does not happen.

Arbitrage and Relative-Value Strategies

Arbitrage strategies examine price differences between equivalent or related instruments. Relative-value strategies examine relationships that may be less exact, such as a historically observed spread between two assets.

We need to account for trading costs, contract terms and the ability to execute every required trade. A displayed price difference is not the same as an available profit.

If one side fills and the other fails, we can be left with unwanted exposure. In a statistical relationship, the expected convergence may never occur. Automation helps process the rules; it does not remove these risks.

Execution Algorithms: TWAP, VWAP and Participation

Execution algorithms help schedule a larger order across smaller trades. Their purpose is often to manage execution, rather than decide whether an asset is worth buying.

With time-weighted average price, or TWAP, an order is spread across time intervals. In a simplified example, we could divide 600 shares into six scheduled requests of 100 shares. Actual fills still depend on market conditions.

Volume-weighted average price, or VWAP, approaches use trading-volume patterns when scheduling orders. Participation algorithms instead aim to trade at a chosen share of observed market volume.

We still face a trade-off: trading quickly may move the price, while waiting can allow the price to move against us. None of these approaches guarantees a particular average price.

Model-Based and Options Strategies

More advanced systems use models to monitor relationships, volatility or portfolio exposure. In options trading, an algorithm might track delta, a measure of an option’s sensitivity to movement in the underlying price.

An illustrative hedge rule could flag when estimated exposure moves outside a defined range. We would still need to specify the hedge instrument, quantity, cost assumptions and execution limits.

Reducing one type of exposure does not remove all risk. Options remain sensitive to factors such as changing volatility and time to expiry. A multi-leg position also needs attention if only some of its orders fill.

What are the Benefits of Algorithmic Trading?

The practical appeal is consistency. Once we define a rule, software can apply it repeatedly without asking us to recalculate every condition by hand.

Algorithms can also check several inputs together. For example, our system could require a valid signal, available funds and an acceptable position size before it sends an order.

Another benefit is traceability. If we record the input data, signal and order response, we can investigate why a trade happened. That is more useful than relying on memory after a busy session.

Automation can reduce impulsive changes at the moment of execution. However, we can still introduce bias when choosing data, adjusting rules or switching a system off after a loss. The quality of our decisions remains part of the process.

Speed is useful only when the underlying rules and controls are sound. A program can repeat a mistake as consistently as it repeats a valid instruction.

What do We Need for Algorithmic Trading?

A working setup brings together trading knowledge, software, data and an authorised connection to a broker. Each part has a different job.

Clear trading rules. We need to define the instrument, signal, quantity, exits and conditions that block an order. Phrases such as “strong momentum” are too vague unless we translate them into measurable conditions.

Suitable market data. The data must match the strategy’s timing and instruments. A daily closing-price series cannot tell us the exact sequence of trades within a five-minute period. Missing observations or inconsistent timestamps can change a test’s result.

Software and technical skills. We can build our own program or use a supported platform. Either way, we need to understand what the system does when inputs are missing, a session expires or an order is rejected.

Broker and API access. An application programming interface, or API, lets software exchange information with another system. Trading access depends on the broker’s supported workflows, account permissions and applicable requirements.

Monitoring and records. We need visibility into active orders, actual positions and errors. A program that is still running may have stopped receiving useful data, so a healthy process alone does not prove the trading system is healthy.

For Indian F&O examples, we must also identify the correct contract, expiry and current lot size. A familiar symbol is not enough to define the instrument being traded.

How We Move From an Idea to a Tested System

Backtesting applies rules to historical data. It helps us examine how those rules would have behaved under stated assumptions. It cannot establish what future trades will earn.

Start with a Written Specification

Before coding, we write down when the system checks a condition, what information is available at that moment and how it responds.

Consider our breakout example. If the rule requires a completed candle, the final closing price is unavailable until that interval ends. Using it to simulate an earlier entry would give the test information the live system could not have known.

We also define what counts as a new signal. Otherwise, the same condition might create another order every time a price update arrives.

Include Costs and Realistic Execution

We evaluate results after the relevant charges and execution assumptions. The difference between an expected price and the price actually achieved is commonly called slippage.

Suppose a hypothetical test shows ₹4,000 in gross gains across 100 completed trades. If total charges and assumed execution costs are ₹45 per completed trade, the net result becomes a ₹500 loss. These are illustrative figures, not Nubra’s fees.

Small average gains leave little room for error in cost estimates. We should also examine losing streaks and drawdown, the decline from a previous peak in the account or strategy value, instead of looking only at total profit.

Test Beyond the Data Used to Design the Rule

Repeatedly adjusting a strategy until its historical chart looks attractive can fit the noise in that dataset. This is known as overfitting.

We can reserve a separate period that was not used to choose the rules, then see how the unchanged system behaves there. Results across different market conditions provide more context than one favourable period.

Data quality matters here too. We need to understand gaps, timestamps and corporate actions such as stock splits. Our historical data FAQs explain relevant data-handling details for Nubra’s API users.

Separate Simulation from Live Execution

Paper trading simulates trades without placing the equivalent real-money orders. A test environment can also help check whether software handles requests and responses correctly. Neither reproduces every feature of a live market.

For example, a simulation might assume an order fills when the price touches a level. In a live order book, other orders may be ahead of ours, or the available quantity may be smaller than we need.

Before any live use, we need defined position limits, alerts and a way to stop new orders. Stopping the program does not automatically cancel open orders or close existing positions; those actions require separate checks.

Keep Checking After the System Starts

Monitoring continues throughout operation. We compare our software’s records with the broker’s order and position records and investigate differences.

If an order request times out, we should not assume it failed. It may already have reached the trading system. Sending it again without checking can create a duplicate order. Our retry and reconciliation guidance explains why uncertain trading actions need a status check first.

Changes also need testing. A small edit to quantity calculation or contract selection can affect every later order.

Algorithmic Trading in India: what Should We Check?

Retail algorithmic trading in India operates within SEBI and exchange frameworks, with brokers playing a central role in access and controls. We should not assume that a working API connection is all that is required for live automation.

The relevant checks can depend on whether we develop the algorithm ourselves or use an algo provider, and on how orders are generated and routed. Before live use, we need confirmation of the applicable registration, order-tagging, authentication and hosting requirements from the broker.

We also need to distinguish permission to operate from evidence of investment performance. Registration or a technical approval does not guarantee profitable trades.

Exploring the API Workflow with Nubra

Once we understand the strategy and testing requirements, we can examine the tools needed to connect our software to a trading platform.

Our Nubra API documentation covers the Python SDK and REST interface, including market data, orders and positions. These resources help us understand the supported building blocks and the information each workflow requires.

The next step is to match those documented capabilities to our specification, then confirm current access and requirements. An API provides a connection; the strategy, testing and monitoring still need careful work.

FAQs
Do We Need Coding Skills for Algorithmic Trading?

Building a custom system requires programming skills or development support. Some platforms provide tools that reduce the amount of code needed. We still need to understand the rules, limits and failure conditions before allowing software to send orders.

Can Algorithmic Trading Make a Profit?

It can, but it can also lose money. Results depend on the strategy, costs, execution and market conditions. We cannot judge profitability from automation alone, and a profitable historical test does not establish future returns.

Is Algorithmic Trading the Same as High-Frequency Trading?

No. High-frequency trading is a specialised form of algorithmic trading that depends heavily on speed and infrastructure. We can also design algorithms that check conditions at slower intervals or schedule orders over a longer period.

How Much Capital do We Need?

There is no single amount that suits every system. We need to consider the instrument, position size, applicable margin, costs and potential losses. A software setup that works technically may still be unsuitable for the capital available.

Does an Algorithm Need AI to Work?

No. A rule that compares a price with a defined threshold can operate without AI. We should be able to explain what triggers an order, what limits its size and what stops the system, regardless of the technology used.

Disclaimer: The information provided in this blog is for educational and informational purposes only and should not be construed as investment advice, financial advice, or a recommendation to buy, sell, or hold any securities or financial products. Investments in the securities market are subject to market risks. Please read all related documents carefully before investing. Readers should conduct their own research and consult a SEBI-registered investment adviser or other qualified financial professional before making any investment decisions. Past performance is not indicative of future results.

Published Sep 21, 2026
Open a Nubra account

Put this into practice

Trade options with a live chain, a strategy builder and real-time Greeks — the same tools this guide describes.

Keep Reading