Skip to content

Blog / Financial Models & Research

Can Machine Learning Predict Whether Nifty Goes Up Tomorrow?

One of the first things that comes to mind when exploring machine learning in the stock market is whether a model can predict the direction of the market for the next trading day. There are several technical indicators available, but does combining them in a machine learning model actually produce better results?

Can Machine Learning Predict Whether Nifty Goes Up Tomorrow?

I tested this using a Random Forest classifier in Python. The objective was simple: predict whether the index would close higher or lower on the next trading day.

For the experiment, I generated synthetic Nifty-like daily price data from January 2016 to October 2026, covering quiet, normal and stressed market conditions. The model used eight inputs, including historical returns, volatility, RSI and the distance from the 50-day and 200-day moving averages.

Rather than randomly splitting the data, I used walk-forward testing. The model was retrained every 125 observations using the available historical data, and predictions were made for the following period. This is closer to how a model would be used when new market data becomes available.

The model correctly predicted the direction on 53.1% of the test days. At first, this might look slightly better than a random prediction. However, simply predicting that the market would go up every day gave an accuracy of 54.1%.

I also wanted to understand whether these predictions could translate into better investment performance.

I simulated a simple strategy where the portfolio remained invested when the model predicted an upward move and moved to cash otherwise. I included a transaction cost of 0.05% each time the strategy switched between the index and cash.

The model-based strategy generated a CAGR of 6.6%, compared with 12.4% for buy and hold. Annualised volatility was lower at 12.1% compared with 14%, but both approaches experienced a maximum drawdown of 29.2%. The model also switched between the index and cash 257 times.

Another interesting observation was the relationship between prediction confidence and actual outcomes. When the model estimated more than a 60% probability of an upward move, the index actually went up on only 35.3% of those days. There were only 34 observations in this group, so the result needs to be interpreted carefully.

For me, the useful part of this experiment was not the prediction accuracy itself, but the comparison against a simple baseline. A model can appear to perform better than chance while still being less useful than a much simpler approach.

This experiment did not establish an advantage from using machine learning to predict next-day market direction. The data was synthetic, and the trading simulation used simplified execution and transaction cost assumptions. Testing with actual Nifty 50 history would be a separate exercise.

This is part of my own learning around financial modelling and machine learning, not an investment recommendation.