Renewable energy has been widely used in grid-connected and standalone hybrid renewable energy systems. These systems require a hybrid energy storage system due to the unpredictable climate and the inequality between the produced energy and the consumed energy. In this paper, a tri-level optimization method is used to optimize the sizing and the energy management of a standalone HRES, simplify the proposed optimization problem, and speed up the convergence process. Horizon prediction and weighting factor strategies are combined with the tri-level technique to find the most appropriate quantity of each element in the project and find the best energy management strategy. The objective function of the proposed methodology aims to minimize the total cost and improve the efficiency of the whole system. The proposed method was investigated on a standalone PV-WT with battery-hydrogen storage in different scenarios. The simulation results from the Matlab toolbox show that the performance indicators (cost and efficiency) are affected by the combination of the weighting factor and the forecasting index. The total productivity was improved by more than 2.5% in some scenarios while the investment cost and the running cost were reduced by values of 49.3% and 28.6%, respectively.