Forecasting stock performance is crucial for formulating a profitable trading approach aimed at achieving significant gains. In addition, prediction results serve as essential prerequisites for creating and optimizing active investment portfolios. However, predicting stock movements presents a formidable challenge due to the presence of various factors that contribute to uncertainty and instability. This paper introduces the use of a long- and short-term memory network to forecast stock movements by analyzing past data as a component to be used in portfolio optimization. To establish an effective investment portfolio, a hybrid portfolio optimization proposal is made to enhance portfolio performance while considering the diversification of assets through categories. The sensitivity of the proposed technique to the parameters is explored to understand the advantages and limitations of the different choices.