Mostly, Electric vehicles (EVs) experience power losses during the discharging and charging period and are connected to the building systems that supply the vehicle. These losses not only affect energy efficiency but also increase operational costs and stress on both the battery and the power grid. In order to ensure trip demand, user discharge and charge costs, and increase the precision of load demand curve prediction, this study proposes a dynamic charge and discharge optimization method that employs the charge and discharge control coefficient in each response period as the control object. By considering user behavior, state of charge, and grid demand simultaneously, the model ensures a balanced interaction between EVs and the power system. In contrast, the distribution network will suffer significantly from the chaotic charging and discharging of large numbers of EVs; however, EVs can be grouped and directed to charge and discharge in a systematic way, which will help delay distribution network investment. Therefore, this model suggested a new hybrid optimization algorithm, with the combination of Whale Optimization Algorithm (WOA) and Particle Swarm Optimization Algorithm (PSOA), to increase the utilization of renewable energy, reduce costs, and enhance grid stability. The hybridization leverages the global search ability of WOA and the fast convergence of PSOA, thereby overcoming the limitations of using each algorithm independently. In comparison to the present models, the proposed approach produced an accurate value of 0.97 for the EV discharging and the charging model. In MATLAB, the proposed framework is verified. The outcomes show that the suggested approach outperforms the conventional techniques for scheduling EV charges and discharges.