The application of 5G-based communication for pilot protection in a distribution network with distributed generators is becoming increasingly widespread, but the existence of a 5G communication transmission data delay adversely affects the rapidity and reliability of the pilot protection based on the principle of the traditional dynamic time warping distance (DTW) algorithm. Therefore, to address this problem, and according to the difference in fault currents between distributed generators and synchronous machines, a new scheme of pilot protection based on the principle of an improved DTW is proposed. The scheme firstly performs cosine transform on the fault current sequence, and then it normalizes the DTW value. Finally, the proposed scheme is verified via simulation. The simulation results show that, compared with the traditional DTW, the proposed algorithm has better anti-delay characteristics and a stronger anti-interference ability, and the scheme can quickly and reliably identify in-zone and out-of-area faults with strong noise resistance. Further, the action times for a single-phase ground fault, two-phase ground fault, two-phase-to-phase fault, and three-phase short-circuit fault were reduced by 2.9 ms, 4.54 ms, 5.81 ms, and 5.89 ms, respectively. In addition, it is also sui for a distribution network with a high wind and photovoltaic penetration rate.