For a broken rail detection system based on ultrasonic guided waves (UGW), the multimodal and dispersion of UGW degrade signal-to-noise ratio (SNR) and range resolution. To improve SNR of the received signals and range resolution, the pulse compression technique based on 13-bit Barker code is presented in this work. Through a PSpice model of the pitch-catch setup, as well as performing field tests, it is shown that coded UGW signals can efficiently improve SNR by 5 dB and have strong noise immunity. As the detection distance increases, the mainlobe width increases linearly while the sidelobe peak levels remain basically unchanged. In addition, to correctly and quickly identify the corresponding transmissions at the receivers, an adaptive peak detection algorithm is proposed, which is based on a digital bandpass tracking filter, moving averaging filters and Hilbert transform. By using some field tests under different detection distances, it is found that compared to the previous works, the proposed adaptive peak detection algorithm has stronger robustness and better anti-noise performance. In addition, the proposed method is easy to integrate into a real-time detection system by proper software design. INDEX TERMS Peaks detection, barker code, pulse compression, long rail breakages detection, UGW.