Investors are inclined to forecast stock values, and conventional studies indicate that using machine learning (ML) for stock price prediction is the most effective method. This study focuses on ML-based stock price forecasting that aims to assist individuals with limited investment capabilities by providing a high-quality approach to price prediction. The research utilizes various characteristics of the current stock price, such as ‘Open,’ ‘Low,’ ‘High, ‘Adj Close’, and ‘Close’. Additionally, it incorporates principal component analysis (PCA), linear discriminant analysis (LDA), and a statistical average method (SAM) to create additional features. These features and the current stock price attributes are combined to form a feature vector for ML methods. The study also emphasizes building a portfolio that reduces investment risk while capitalizing on the expected upward movement of stock prices. Experimental results indicate that incorporating the SAM-price feature associated with the ML technique, bidirectional long short-term memory (Bi-LSTM), leads to superior forecasting accuracy compared to existing approaches. It’s evident from various previous literary works that various supervised learning methods have been successful regarding stock price forecasting. Our research is dedicated to producing a novel approach to generate better price accuracy by forecasting and an effective portfolio that can be beneficial for the general public. The investigation reveals an accuracy rate of 98.14% when applied with the SAM-price feature defined by AFD, surpassing the accuracy achieved by traditional pricing features alone. Additionally, as a novel price feature, AFD generates no over-fitting. Furthermore, the portfolio generated using the SAM-price function demonstrates a return on investment of 145.475% and a Sharpe ratio value of 77.62, indicating a favorable risk-return trade-off.