Computer-implemented method for detecting a presence of a train on a track section inserted in a track circuit, at one end of which a local voltage Vin_L, equal to a local periodic signal having frequency f L, is sent and that produces at the other end of which a field voltage Vin_C, wherein the field voltage Vin_C is equal to the sum of a field periodic signal VC(t) having frequency f L and a noise N(t), whereby Vin_C = VC(t) + N(t), comprising the following steps: S-A. acquiring the local voltage Vin_L and the field voltage Vin_C of the track circuit for an interval T of integration having a start time assumed as time origin; S-B. calculating a cross-correlation at the time origin C mis of the local voltage Vin_L and the field voltage Vin_C acquired in step S-A and the derivative of said cross-correlation at the time origin C' mis; S-C. determining a phase shift φ of the field voltage Vin_C with respect to the local voltage Vin_L according to the formula φ = − arctg C ′ mis 0 C mis 0 S-D. comparing the phase shift φ determined in step S-C with a predetermined maximum phase shift threshold R; S-E. if the phase shift φ determined in step S-C exceeds the predetermined maximum phase shift threshold R, then signaling the presence of a train on said track section, otherwise executing the following steps; S-F. calculating a product VL eff _ mis ∗ VC eff _ mis of the effective values of the local voltage Vin_L and field voltage Vin_C acquired in step S-A in the interval T of integration, and calculating the effective value VL eff _ mis in the interval T of integration of the local voltage Vin_L acquired in step S-A and the effective value VC eff_mis in the interval T of integration of the field voltage Vin_C acquired in step S-A; S-G. normalising the cross-correlation at the time origin C mis with respect to the product VL eff_mis * VC eff_mis of the effective values calculated in step S-F, obtaining a normalised cross-correlation at the time origin C mis_norm; S-H. calculating a maximum value C max of said cross-correlation normalised to the product VL eff_mis * VC eff_mis of the effective values calculated in step S-F through the formula C max = C mis _ norm 0 cosφ S-J. calculating an effective value VC eff of the field periodic signal VC(t) in the interval T of integration through the formula VC eff = C max ∗ VC eff _ mis S-K. comparing the effective value VC eff of the field periodic signal VC(t) with the effective value VL eff_mis of the local voltage Vin_L acquired in step S-A; S-L. if the effective value VC eff of the field periodic signal VC(t) differs from the effective value VL eff_mis of the local voltage Vin_L acquired in step S-A over a predetermined maximum effective value difference threshold S, then signaling the presence of a train on said track section. S-A. acquiring the local voltage Vin_L and the field voltage Vin_C of the track circuit for an interval T of integration having a start time assumed as time origin; S-B. calculating a cross-correlation at the time origin C mis of the local voltage Vin_L and the field voltage Vin_C acquired in step S-A and the derivative of said cross-correlation at the time origin C' mis; S-C. determining a phase shift φ of the field voltage Vin_C with respect to the local voltage Vin_L according to the formula φ = − arctg C ′ mis 0 C mis 0 S-D. comparing the phase shift φ determined in step S-C with a predetermined maximum phase shift threshold R; S-E. if the phase shift φ determined in step S-C exceeds the predetermined maximum phase shift threshold R, then signaling the presence of a train on said track section, otherwise executing the following steps; S-F. calculating a product VL eff _ mis ∗ VC eff _ mis of the effective values of the local voltage Vin_L and field voltage Vin_C acquired in step S-A in the interval T of integration, and calculating the effective value VL eff _ mis in the interval T of integration of the local voltage Vin_L acquired in step S-A and the effective value VC eff_mis in the interval T of integration of the field voltage Vin_C acquired in step S-A; S-G. normalising the cross-correlation at the time origin C mis with respect to the product VL eff_mis * VC eff_mis of the effective values calculated in step S-F, obtaining a normalised cross-correlation at the time origin C mis_norm; S-H. calculating a maximum value C max of said cross-correlation normalised to the product VL eff_mis * VC eff_mis of the effective values calculated in step S-F through the formula C max = C mis _ norm 0 cosφ S-J. calculating an effective value VC eff of the field periodic signal VC(t) in the interval T of integration through the formula VC eff = C max ∗ VC eff _ mis S-K. comparing the effective value VC eff of the field periodic signal VC(t) with the effective value VL eff_mis of the local voltage Vin_L acquired in step S-A; S-L. if the effective value VC eff of the field periodic signal VC(t) differs from the effective value VL eff_mis of the local voltage Vin_L acquired in step S-A over a predetermined maximum effective value difference threshold S, then signaling the presence of a train on said track section.