The stock market data analysis has received interest as a result of technological advancements and the investigation of new machine learning models, since these models provide a platform for traders and business people to choose gaining stocks. The business price prediction is a challenging and extremely complex process due to the impact of several factors on company prices. The numerous patterns that the stock market goes, they have been the focus of extensive research and analysis by numerous experts. There are several large data sets accessible, an artificial intelligence and machine learning techniques are developing quickly, and because of the machine’s improved computational power, complex stock price prediction algorithms can be developed. This paper presents stock market index prediction based on market trend using long short-term memory (LSTM). Using built-in application programmable interface (API), Yahoo Finance offers a simple method to programmatically retrieve any historical stock prices of an organization using the ticker name. The standard and poor’s 500 index (S&P 500 index) include the firms that have been taken into consideration here. Utilizing the selected input variable, single-layer and multi-layer LSTM models are implemented, and the measurement parameters of mean absolute error (MAE), root mean square error (RMSE), and correlation coefficient (R) are used to compare each performance. Nearly all of the real closing price’s curve and the prediction curve’s closing price for test data overlap. A potential stock investor may benefit significantly from such a prediction by using it to make well-informed choices that would increase his earnings.