This paper presents an effective method, named modified coyote optimization algorithm (MCOA), for determining the optimal integration of photovoltaic units (PVs), wind turbine units (WTs), battery energy storage system (BESS), and capacitor bank (CB) in the IEEE 69-bus radial distribution system. This research is developed with the goal of minimizing the total costs of investment, operation and maintenance (O&M) for PVs, WTs, BESS, and CB as well as energy purchase cost from the main grid considering time-varying load demand and generation units. The simulation results demonstrate total costs in operating the integrated system can be significantly minimized by the proper connection of PVs, WTs, BESS, and CB. On the other hand, the study also considers the test system under the condition of many nonlinear loads, and the approach has been successful in mitigating harmonics to the IEEE Std. 519. In addition, the proposed method (MCOA) is also compared with the original coyote optimization algorithm (COA) and slime mould algorithm (SMA) to prove its effectiveness in solving the optimization problems.