This study develops a method for accurately forecasting solar radiation (SR), wind speed (WS), and air temperature (AT) for the coming 24 hours in order to predict energy production from photovoltaic (PV) panels and wind turbines (WT) in positive energy buildings. Input data are pre-processed through variational mode decomposition (VMD) for broadband feature extraction, which is then decomposed into smooth modes. The application of the Salp Swarm Algorithm (SSA) aims to optimize VMD parameters to enhance the precision of feature extraction. A thorough data analysis is performed to identify the essential input features. Residual pre-processing between input variables and their decomposed modes further enhances model performance. The stacking algorithm (SA) is used to predict both modes and residuals of the input data. Performance evaluation using metrics such as root mean square error (RMSE), normalized root mean square error (NRMSE), mean absolute error (MAE), and normalized mean absolute error (NMAE) indicates a reduction in error rates across measurement scales. For example, under adverse weather conditions, the NRMSE and NMAE for PV power are 2.50% and 1.95%, respectively.