Formation targets have the characteristics of close distance, RCS difference and strong motion correlation. Radar should have enough resolution and anti-jamming ability to detect formation targets in the complex electromagnetic environment. The stepped frequency signal can be synthesized into a large bandwidth signal, so as to improve the range resolution and enhance the recognition performance of formation targets. In order to detect small targets next to large targets in formation targets, the signal needs to have low sidelobe characteristics. In this letter, we propose an optimized stepped frequency signal that can be synthesized into a large bandwidth with low autocorrelation sidelobes and a stopband to against narrowband interference. The proposed method can well detect small targets next to large target in formation, and has a certain narrowband anti-jamming ability. The simulation experiment results verify the advantages of the proposed waveform.