It is a common idea to imitate the body wave of fish to swim for motion control of the robotic fish. Because of its high degree of freedom, the multi-joint robotic fish can imitate a variety of fish gaits. How to select the best combination of body wave parameters according to the hardware constraints and mission objectives of the multi-joint robotic fish is a subject worth exploring. In this paper, a deep reinforcement learning method is proposed to optimize the body wave followed by a multi-joint robotic fish. To begin with, we built a robotic fish with five driving joints. Then, the simulation model of the robotic fish is constructed. We use a neural network to train the model based on a Subcarangiform body wave and obtain the best combination of parameters for different targets. Finally, we carried out experiments on the robotic fish prototype, compared the effects of different body wave models, and verified the feasibility of deep reinforcement learning to optimize body wave parameters.