Random mobility and energy constraint are two main factors affecting system performance in mobile sensor networks, which cause many difficulties to system design. It is necessary to develop high-efficiency algorithms and protocols for mobile sensor networks to adapt to dynamic network environment and energy limitation. In this paper, a new clustering algorithm based on residual energy difference ratio is presented to improve system performance. Firstly, it is an energy-efficient algorithm. The residual energy of sensor nodes and average residual energy of system are considered in the residual energy difference ratio, which effectively avoid the nodes with low residual energy being selected as cluster heads. An energy-optimal scheme is used in cluster formation phase to minimize energy consumption. Secondly, it is a dynamic algorithm. The system dynamically clusters the sensor nodes according to the data transmission delays. It makes the whole system adapt to the random mobility of sensor nodes. The NS2 software is used to simulate the new clustering algorithm. The simulation experiments can verify the validity of the proposed theory.