Precise stock market prediction is crucial for investors, but the volatility of the stock market is influenced by multiple factors such as public sentiments, business news, and related product volatility. While several algorithms have been proposed to predict the stock exchange index based on historical data, they are not ideal as external factors play a critical role in market volatility. To address this issue, we proposed a machine learning model that incorporates historical data with external factors such as social media sentiments, oil and gold trends, and financial news data to enhance prediction accuracy. Our study used HPQ, IBM, ORCL, and MSFT stock market datasets to validate the effectiveness of the proposed model, including an analysis of the impact of Covid19 on companies. Our experimental results showed the highest accuracy of 87.2% using oil and sentiment datasets. Additionally, we identified that social media significantly affects IBM stocks, and the GBM (Gradient Boosting Classifier) classifier produced consistent results.