The integration of renewable sources and energy storage in residential microgrids offers energy efficiency and emission reduction potential. Effective energy management is vital for optimizing resources and lowering costs. In this paper, we propose a novel approach, combining the imperialist competitive algorithm (ICA) with particle swarm optimization (PSO) as ICA-PSO to enhance energy management. The proposed energy management system operates in an offline mode, anticipating data for the upcoming 24 h, including consumption predictions, tariff rates, and meteorological data. This anticipatory approach facilitates optimal power distribution among the various connected sources within the microgrid. The performance of the proposed hybrid ICA-PSO algorithm is evaluated by comparing it with three selected benchmark algorithms, namely the genetic algorithm (GA), ICA, and PSO. This comparison aims to assess the effectiveness of the ICA-PSO algorithm in optimizing energy management in multi-source residential microgrids. The simulation results, obtained using Matlab 2023a, provide clear evidence of the effectiveness of the hybrid ICA-PSO algorithm in achieving optimal power flows and delivering substantial cost savings. The hybrid algorithm outperforms the benchmark algorithms with cost reductions of 4.47%, 14.93%, and 26% compared to ICA, PSO, and GA, respectively. Furthermore, it achieves a remarkable participation rate of 50.6% for renewable resources in the energy mix, surpassing the participation levels of the ICA (42.88%), PSO (40.51%), and GA (38.95%). This research contributes to the advancement of power flow management techniques in the context of multi-source residential microgrids, paving the way for further research and development in this field.