This paper aims to explore a method of constructing dynamically adjusted investment portfolios through the combination of rolling windows and mean-variance models. The construction of investment portfolios plays a crucial role in financial markets by effectively diversifying risks and achieving stable investment returns. This study analyzed adjusted closing price data from five stocks (AAPL, JPM, JNJ, XOM, and PG), sourced from Yahoo Finance. The rolling window method was employed to predict future stock prices and construct investment portfolios based on these predictions. This study calculated annualized average return and covariance matrix for each window. The mean-variance model and optimization algorithms were then used to determine the optimal weights for daily portfolio composition. The results demonstrate the high accuracy of the rolling window method in predicting short-term stock prices. Notably, Procter & Gamble (PG) and Johnson & Johnson (JNJ) exhibited the lowest prediction errors. Investment portfolios based on rolling window predictions performed well over a certain period. Nevertheless, the S&P 500 index did not show a substantial disadvantage compared to their long-term performance. This research provides dynamic portfolio optimization methods of practical value for investors in financial markets.