This paper proposed a unified active power optimization control of wind farms under wake effect. It takes the sum of the kinetic energy variation and pitch angle variation as the optimization objective and used the particle swarm algorithm to achieve the optimization results. The main feature of the proposed method is that it unifies the kinetic energy optimization under a low wind speed area, the pitch angle and kinetic energy trade-off optimization under a medium wind speed area, and the pitch angle optimization under a high wind speed area. Combined with the de-loaded power constraint, it can flexibly reach various optimal operating states of the wind farm. The simulation results show that the proposed method optimizes the rotor speed and pitch angle in different wind speed areas, and releases kinetic energy and/or increases the output power of the wind farm to provide frequency support by switching the operating states.