The production of solar energy at altitudes higher than 3800 m above sea level is not constant because the relevant factors are highly varied and complex due to extreme solar radiation, climatic variations, and hostile environments. Therefore, it is necessary to create efficient prediction models to forecast solar production even before implementing photovoltaic systems. In this study, stacking techniques using ElasticNet and XGBoost were applied in order to develop regression models that could collect a maximum number of features, using the LASSO, Ridge, ElasticNet, and Bayesian models as a base. A sequential feature selector (SFS) was used to reduce the computational cost and optimize the algorithm. The models were implemented with data from a string photovoltaic (PV) system in Puno, Peru, during April and August 2021, using 15 atmospheric and photovoltaic system variables in accordance with the European standard IEC 61724-20170. The results indicate that ElasticNet reduced the MAE by 30.15% compared to the base model, and that the XGBoost error was reduced by 30.16% using hyperparameter optimization through modified random forest research. It is concluded that the proposed models reduce the error of the prediction system, especially the stacking model using XGBoost with hyperparameter optimization.