To improve the locomotion performance of legged robots, the swing leg retraction (SLR) technique is investigated in a hydraulic biped robot. First, the influence of SLR on the locomotion performance of the hydraulic biped robot is analyzed in theory and simulations based on an extended spring load inverted pendulum model. The influence contains three performance indicators: energy loss/effiency, friction/ slipping, and impact/compliance. Second, by synthesizing three performance indicators, using unified objective method and particle swarm optimization algorithm, the optimal SLR rate for gait planning based on Bezier curve is addressed.Finally, experiments are implemented to validate the effectiveness and feasibility of proposed method. And, the results show that the SLR technique is useful to reduce the impact force, improve the robot's locomotion stability and make room for impedance performance improvement of compliance controller. This research provides an insight for locomotion control of hydraulic legged robots.