Fully variable valve technology of diesel engine can change the movement parameters of valve flexibly, and then the performance of engine can be improved. But the actual valve movement can’t track the optimal valve profile due to the nonlinear characteristics of hydraulic system in transient work conditions, which make the engine performance be deteriorated. To solve the problem, the paper introduced the idea of dynamic programming (DP) into the control of FVVA system. Firstly, the paper presented a new electro-hydraulic FVVA system. To verify the FVVA system, the GT-suite models of FVVA system and engine were built. Secondly, for the purpose of achieving optimal performance, based on the NSGA-II genetic algorithm, we got the database of the optimal valve profile movement parameters using modeFRONTIER platform. In database, there are multiple feasible solutions for one work condition. To achieve the optimal engine performance in every cycle, according to the real-time valve movement profile, the controller will choose different solutions with DP method in one cycle based on the database obtained before. The DP controller can make the engine performance to be optimal according to the real-time valve profile in transient conditions. In steady conditions, optimal valve profiles can be reached by a PID controller. Thirdly, the DP controller and PID controller were designed with Simulink separately. The DP controller will adjust valve control parameters in one cycle and the PID controller will adjust the parameters cycle by cycle. At last, the DP-PID controller was compared with the single PID controller which adjust control parameters once in one cycle. The simulation results show that the performance of engine with DP-PID controller is improved compared to the PID controller especially in transient conditions. The average brake power can be improved by 3.3% to 4.7% compared to single PID controller.