Register
Learn guide

Predicting Price Action with Supervised Learning

Machine learning uses algorithms that learn patterns from data rather than following rules written by hand. In trading, it is used to forecast short-term moves, classify market conditions, size positions and execute orders. It is also one of the easiest ways to fool yourself, because financial data is noisy and powerful models can find patterns that are not there.

QuantPower Research · Updated 14 Nov 2026 · 17 min read

This guide explains how supervised learning is applied to price prediction, what it takes to build a model properly, a worked example of why a model can be right more often than not and still lose money, the pitfalls specific to markets, what machine learning can and cannot do, how large language models fit in, and how SEBI's rules apply to strategies built on machine learning. It is written for traders in India who want to know what the tools can do before they spend months building one.

Where machine learning is used in trading

UseWhat the model doesExample
ForecastingPredicts a return, a direction or a volatilityWhether Nifty futures rise over the next 30 minutes
Classifying conditionsLabels the market's stateTrending, range-bound or volatile, to switch strategies on or off
Position sizingPredicts risk to set sizeSmaller positions when predicted volatility is high
ExecutionPredicts short-term liquidity and price impactWhen to split and send a large order
Reading textTurns news, filings or transcripts into signalsTone of a results announcement
Spotting anomaliesFlags unusual behaviourAn algo sending orders far outside its normal pattern

Large firms use all of these. For an individual trader, the realistic uses are classifying conditions, sizing positions and reading text; forecasting short-term prices is where most attempts fail. The difference is not only skill. Forecasting needs a small edge applied thousands of times at low cost, which favours firms with large data, fast systems and low charges; classifying conditions needs a modest edge applied to a few decisions a week, which an individual can test properly with the data a broker provides.

A short history of machine learning in finance

The term "machine learning" was coined by Arthur Samuel in 1959, describing a program that learned to play draughts better than its author.1 For decades the methods stayed in research labs. Neural networks gained a practical training method in 1986, when David Rumelhart, Geoffrey Hinton and Ronald Williams described backpropagation.2 Tree-based methods followed: Leo Breiman's random forests and Jerome Friedman's gradient boosting, both published in 2001, are still among the most used models for tabular data, the rows and columns that market data comes in.3

Finance adopted these tools early but quietly. Quantitative hedge funds used statistical learning from the 1980s, and by the 2000s machine learning was part of execution and market-making systems at large banks and trading firms. Deep learning's breakthrough in image recognition in 2012 brought a wave of attempts to apply neural networks to prices. Careful studies, such as Shihao Gu, Bryan Kelly and Dacheng Xiu's 2020 study of US stocks, found that flexible models did improve on linear ones, but by modest amounts relative to the noise in returns.4 Marcos López de Prado's 2018 book on financial machine learning set out why most published results do not survive honest testing.5

In India, SEBI asked market intermediaries in January 2019 to report the AI and machine-learning systems they offer or use.6 Since 2022, large language models have added a new kind of tool, one that reads and writes text, and in 2025 SEBI consulted on guidelines for the responsible use of AI and machine learning in the securities market.

What supervised learning is

Supervised learning trains a model on examples where the answer is known. Each example has:

  • Features: the inputs, such as recent returns, volatility, volume or option data.
  • A label: the outcome to predict, such as whether Nifty rises over the next 30 minutes, or by how much.

The model learns a relationship between features and labels on past data, then makes predictions on new data. Unsupervised learning, by contrast, looks for structure without labels, for example grouping trading days into types; reinforcement learning learns actions by trial and reward, and is mostly used in execution research.

Common models

ModelStrengthsWeaknesses
Linear and logistic regressionSimple, fast, interpretableMisses non-linear patterns
Decision trees and random forestsCapture interactions, handle mixed dataCan overfit without limits
Gradient-boosted treesOften strong on tabular dataMany settings to tune
Neural networksFlexible, handle large and complex dataNeed much data, hard to interpret, easy to overfit

In research on predicting stock returns, tree-based models and neural networks have improved on linear models, but the gains were modest relative to the noise in returns. Prediction in markets is hard even for the best models, which is a reason to start simple.

Features traders commonly use

Features must be known at the moment of the prediction. Common choices for Indian index trading include:

  • Recent returns over several windows, such as the last 5, 15 and 60 minutes and the previous day.
  • Volatility, measured from recent price ranges, and India VIX.
  • Volume and open interest in futures and the main option strikes.
  • Option data, such as the at-the-money implied volatility and the put-call ratio of open interest.
  • Calendar features: time of day, day of the week and the number of days to the next expiry.
  • Market breadth: how many index stocks are up or down.

More features are not better. Each one adds a way for the model to fit noise. A handful of features with a clear reason behind each usually beats a hundred chosen because they were available. Before adding a feature, write one sentence on why it should help predict the label. If you cannot, leave it out, and test the model again without it to see whether it was helping at all.

Building a model properly

Diagram of market data split by time into train, validate and test periods, against a random shuffle, with walk-forward windows (illustration)
  1. Define the question. For example: will the next 30-minute return of Nifty futures be positive?
  2. Build features from past data only. Every feature must be known at the moment of the prediction.
  3. Split data by time. Train on an earlier period, validate on a later one, test on the latest. Never shuffle time series data randomly, which lets the model learn from the future.
  4. Tune on validation, judge on test. Use the test period once, at the end.
  5. Walk forward. Retrain on a rolling window and test on the next period, repeatedly. See walk-forward testing.
  6. Turn predictions into a strategy. Decide how a prediction becomes a trade: thresholds, position size and exits.
  7. Include costs. A model can be accurate and still lose money if its edge is smaller than costs.

A worked example: right more often, and still losing

Suppose a model predicts the direction of Nifty futures over the next 30 minutes and is right 53% of the time on data it has never seen, which would be a good result in research. Suppose also that the average 30-minute move, up or down, is 20 points, and the model trades one lot every time it makes a prediction.

  • Before costs: the expected result per trade is 0.53 × 20 − 0.47 × 20 = 1.2 points.
  • Costs: a round trip in one lot of Nifty futures costs about 14.9 points in brokerage and statutory charges at ₹20 an order, at the STT rate in force since 1 April 2026.
  • After costs: about −13.7 points a trade.

To break even after costs with 20-point moves, the model would need to be right about 87% of the time. No honest short-term direction model comes close. The edge from accuracy is real but tiny; the costs are large and certain. This is the most common way a promising model fails, and it is visible before a single rupee is risked, if the test includes costs.

The same arithmetic suggests where machine learning can help: in decisions where a small edge is applied to a large move, such as choosing which days to run a strategy at all, or how large to size it, rather than in predicting every small move.

Labels that suit trading

A label of "up or down in 30 minutes" ignores what a trader actually does: enter with a stop and a target. A better label asks which happens first: the target, the stop, or a time limit. López de Prado calls this the triple-barrier method.5 It produces labels that match a real trade's outcome, so a model trained on them learns something closer to what the strategy needs. It also makes the cost of a wrong prediction visible, because a stop-out is labelled as a loss of a known size.

Pitfalls specific to markets

Data leakage

Leakage happens when information from the future slips into the features. Common examples: using the day's closing price to predict an intraday move, normalising data using statistics from the whole dataset, or labels that overlap with the next training example. Leakage produces models that look brilliant and fail live. A quick test: if the model's results on unseen data are far better than anything you would expect, look for leakage before you look for anything else.

Non-stationarity

Markets change. Relationships that held in one period can weaken or reverse in another. A model trained on a calm period may fail in a volatile one. Indian derivatives have had several rule changes since 2024, such as one weekly expiry per exchange, larger contracts, the move of NSE expiries to Tuesday and higher STT from April 2026, each of which can change the patterns a model learned.

Low signal-to-noise

Price changes are mostly noise. A model that predicts direction correctly 52% of the time may be useful, or may be luck. Tiny edges are hard to tell apart from chance and easily wiped out by costs.

Overfitting

Flexible models with many parameters can memorise past data. The more models and settings you try, the more likely the best one is a fluke. See avoiding overfitting.

Accuracy is not profit

A model that is right 60% of the time but loses more on wrong calls than it makes on right ones loses money. Evaluate models on the strategy's P&L after costs, not just on accuracy.

Evaluating a model the way a trader would

Accuracy is the share of predictions that were right. For a trader, three other measures matter more:

  • Precision of the trades taken. If the model only trades when it is confident, how often is it right on those trades?
  • The size of wins and losses. A model that is right on small moves and wrong on large ones loses money at any accuracy.
  • The strategy's result after costs, with its drawdown, its worst month and its result on data it was not built on.

A useful habit is to compare the model's strategy with a simple baseline: the same entries without the model, or a plain rule such as a moving-average filter. If the model does not beat the baseline after costs on unseen data, it is not adding anything, however impressive its accuracy looks.

Explaining what a model does

A model you cannot explain is hard to trust and, if you offer it to others, hard to classify under SEBI's rules. Three common tools help. Feature importance ranks the inputs by how much the model relies on them. Partial dependence plots show how the model's prediction changes as one input moves while the others are held steady. Methods based on Shapley values, such as SHAP, break a single prediction down into the contribution of each input. None of these makes a complex model fully transparent, but they catch the worst problems: a model that leans heavily on the day of the month, or on a feature that leaked the answer, usually shows it in its importance ranking. If the explanation does not make sense to a trader, the model probably learned noise.

Machine learning against plain rules

Rules and models are not opposites. Many working strategies combine them: a rule decides the trade, and a model decides whether conditions suit it. For example, an option-selling rule might run only on days a simple classifier marks as range-bound, and a breakout rule only on days it marks as trending. The rule stays transparent and testable; the model acts as a switch. If the switch fails, the damage is limited to running the rule on the wrong days, which a backtest of the rule alone has already priced.

A worked example: a classifier as a switch

Take a weekly short strangle on Nifty that you already trade by rules: sell calls and puts at a set distance on the morning of the trade, with a stop on each leg and an exit time. Its backtest shows that most of its losses come from a small number of days when the index trended strongly. The question for a model is not "where will Nifty go" but "is today likely to be a trending day?"

  1. Label past days as trending or not, using a fixed definition, such as a close more than 1% from the open with the day's range mostly in one direction.
  2. Choose a few features known before the entry: the overnight gap, the change in India VIX from the previous close, the previous day's range, the first 15 minutes' range and the number of days to expiry.
  3. Train a simple model, a logistic regression or a small tree, on the earlier years, and test it on the latest year it has never seen.
  4. Use it as a switch. On days the model marks as likely trending, the strangle does not trade; on other days it runs exactly as before.
  5. Compare the strategy with and without the switch on the test year, after costs, looking at the result, the drawdown and the number of days skipped.

If the switch removes more of the bad days than the good ones, it adds value; if it mostly skips days at random, the strategy is better without it. Either way, the strangle's own rules, stops and limits stay as they were, and the model's worst case is that it switches the rule off on the wrong days.

Data for machine learning in Indian markets

A model is only as good as its data, and Indian market data has some traps of its own:

  • Where to get it. Daily data for stocks and derivatives is published by the exchanges in their end-of-day files. Intraday candles come from your broker's historical data service, which usually covers a limited stretch of history. Option chain snapshots during the day generally have to be collected as you go.
  • Index changes. The stocks in Nifty change over time. A model trained only on today's members ignores the companies that dropped out, which makes the past look better than it was.
  • Corporate actions. Splits, bonus issues and dividends change prices overnight. Use adjusted prices, or the model will learn from moves that never happened.
  • Contract rolls. Futures and options expire. A continuous series for a model must be built by joining contracts, and the join must not create a fake jump.
  • Rule changes. Lot sizes, expiry days, trading hours and taxes have all changed since 2024. Mark the dates in your data so you can test whether the model behaves differently on each side of a change.
  • Time stamps. Keep every record in Indian time, check that candles line up across instruments, and drop market holidays.

How much data a model needs

Flexible models need many independent examples. A model that predicts 30-minute moves on Nifty can make about a dozen predictions a day, a few thousand a year, but overlapping windows and days that move together mean far fewer of those are independent. As a rough guide, a model with a handful of features can be tested on two or three years of intraday data; a neural network with many inputs needs far more than that, more than most individual traders have. When data is short, simpler models and fewer features are not a compromise; they are the method most likely to hold up on new data.

What machine learning can and cannot do

It can:

  • Find combinations of signals that simple rules miss.
  • Classify market conditions, such as trending or range-bound, to switch strategies on or off.
  • Improve execution, for example by predicting short-term liquidity.
  • Help size positions based on predicted volatility.

It cannot:

  • Predict prices reliably over long periods.
  • Remove the need for risk controls, stops and position limits.
  • Replace a clear reason for why a strategy should work.

Large language models and trading

Large language models, such as the ones behind Claude and ChatGPT, are a different kind of machine learning. They are trained on text, and they read and write it well. In trading they are useful for work around the trade: summarising a results announcement, explaining an indicator, turning a plain-language rule into a precise one, or writing the code for a backtest. They are not price-forecasting models, and they can state wrong facts with confidence, so every number they give should come from data or a tool, not from the model's memory.

QuantPower uses a language model in this way. Quanty, the assistant in the app, can build a strategy from your words, backtest it and run a risk check, and saves it switched off; it never switches an algo on. Through Connect AI, your own AI app can read your account, backtest your rules and save an algo switched off, with your permission. Both are software, not advisers: they give no tips and do not say which strategy will make money.

Machine learning and SEBI's algo framework

Under SEBI's framework for retail algorithmic trading, which has applied in full since 1 April 2026, algorithms offered to retail investors through brokers are classified as white-box, where the logic is disclosed and can be replicated, or black-box, where it is not. Providers of black-box algorithms must be registered with SEBI as Research Analysts and maintain a research report for each algorithm.7 Many machine-learning strategies are hard to explain fully, so anyone planning to offer one to others should understand how it would be classified. Our guide to SEBI rules for option trading covers the framework.

For your own trading, the rules on the order route still apply whatever drives the decision: orders through your broker's API from a registered static IP, a daily login, and fewer than 10 orders a second unless the algo is registered.

From a model in Python to orders at your broker

Most traders build models in Python, where the data tools are. Moving a model's output into live trading is a separate problem from building the model, and it is where many projects stall: the daily broker login, the static IP, order handling and risk limits all need to work every day.

QuantPower gives a model a route that keeps those parts in one place. Its webhooks are private URLs that any program able to call a URL can hit. Your model, running wherever you run it, calls an entry webhook when it signals and an exit webhook when it does not; the webhook switches your linked algos on and off, and the algos place orders through QuantPower's order path, with the account's daily loss limit, Smart Exit and kill switch above them. Up to 20 webhooks can each link up to 10 algos, and webhooks cost no tokens; a live algo costs 200 tokens per 28 days. Test the whole chain in Forward test, with test money, before it touches your account.

Getting started

If you want to explore machine learning for trading:

  1. Start with simple models and a clear question.
  2. Build a clean dataset with careful timestamps.
  3. Split by time and walk forward.
  4. Compare the model's strategy with a simple rule-based baseline.
  5. Forward test any model before using real money.

QuantPower's strategy builder and backtesting focus on transparent, rule-based strategies, which are a good baseline to compare any model against. Charts, the option chain, the screener and the strategy builder are free; a backtest costs 2 tokens, with the first 10 each week free (1 token = ₹1, GST extra). See pricing.

Common mistakes

  • Shuffling time series data before splitting it into training and test sets.
  • Reporting accuracy and not P&L after costs.
  • Testing many models and reporting the best one without correcting for the number tried.
  • Using features that were not known at the time, such as the day's close in an intraday model.
  • Retraining on all the data, including the test period, and then quoting the test result.
  • Skipping the plain baseline, so there is no way to tell whether the model adds anything.

Where machine learning in trading is going

Three changes are under way. Tools that once needed a research team now run on a laptop, so more traders try machine learning and the share of untested models in circulation grows. Language models are making it easier to describe, code and test strategies, which raises the value of honest testing rather than replacing it. And regulators, in India and elsewhere, are moving towards rules that make the logic of algorithms offered to the public explainable and their providers accountable. The models will keep improving. The noise in prices, the cost of trading and the temptation to overfit will not go away.

Start with 500 free tokens

Connect your broker, build a strategy and test it on paper before a single live order goes out.

Frequently asked questions

Can machine learning predict the stock market?

It can find weak patterns in some conditions, but market returns are mostly noise. Reliable long-term prediction is not realistic.

Which machine learning model is best for trading?

There is no single best model. Simple models are a good starting point; tree-based models often do well on tabular market data. Judge any model by out-of-sample strategy results after costs.

What is data leakage in trading models?

When information that would not have been available at prediction time slips into the model's inputs, making results look far better than they would be live.

Do I need coding skills for machine learning in trading?

Usually yes. Building and testing models properly requires programming, commonly in Python, and careful handling of data.

How accurate does a trading model need to be?

It depends on the size of the moves it trades and on costs. A model trading 20-point Nifty futures moves at a cost of about 15 points a round trip would need to be right nearly nine times in ten to break even, which no honest short-term model achieves. Models that decide when to run a strategy, rather than predicting every move, need far less.

Can my own model send signals to QuantPower?

Yes. A program that can call a URL can hit a QuantPower webhook, which switches your linked algos on or off. The algos then trade through QuantPower's order path, with your account's risk limits above them.

References

  1. Samuel, A. L. (1959). Some Studies in Machine Learning Using the Game of Checkers. IBM Journal of Research and Development, 3(3), 210–229
  2. Rumelhart, D. E., Hinton, G. E. and Williams, R. J. (1986). Learning Representations by Back-propagating Errors. Nature, 323, 533–536
  3. Breiman, L. (2001). Random Forests. Machine Learning, 45, 5–32; Friedman, J. H. (2001). Greedy Function Approximation: A Gradient Boosting Machine. Annals of Statistics, 29(5), 1189–1232
  4. Gu, S., Kelly, B. and Xiu, D. (2020). Empirical Asset Pricing via Machine Learning. Review of Financial Studies, 33(5), 2223–2273
  5. López de Prado, M. (2018). Advances in Financial Machine Learning. Wiley
  6. SEBI, circular on reporting of artificial intelligence and machine learning applications and systems offered and used by market intermediaries, January 2019 (sebi.gov.in)
  7. SEBI, circular on safer participation of retail investors in algorithmic trading, 4 February 2025, in force for every broker from 1 April 2026 (sebi.gov.in)
Machine learning models can fail without warning when markets change. Trading involves substantial risk. This guide is for education and is not investment advice.