The problem of train trajectory optimization of two successive trains on the same line is studied in this paper. The two-train optimal control problem is formulated by using the multiple-phase method of optimal control, in which the train schedules as well as train performance parameters and track gradients, curves and speed limits are taken into account. The objective is to ensure a smooth, safe, punctual, and energy-efficient train operation. A green-wave (GW) policy is adopted to ensure that the trains proceed safely under all green signals. Special objective functions and constraints are developed in case of train delays. The method is applied in a case study of two successive trains running on a railway line with various input delays showing the benefit of the GW policy and the ability of delay recovery.