To achieve effective prevention of cascading faults in the economic dispatch of AC and DC systems, this paper proposes a preventive control strategy considering both safety and economy, and constructs a bi-level nonlinear optimization model. Initially, a mathematical criterion for discriminating cascading tripping is formulated based on the action characteristics of relay protection. Subsequently, a static safety margin index, using unit active output as the control variable, is established to measure the safety level of the AC/DC system. Then, an economic index is derived by integrating network loss, unit power supply cost, and environmental management cost. The inner-layer model aims to solve the static safety margin, while the outer-layer model utilizes the safety margin solved by the inner layer as a constraint to minimize the comprehensive cost of the grid.Furthermore, a two-layer particle swarm algorithm is proposed to solve the bi-level preventive control model. Additionally, a Jacobi matrix preprocessing method combined with sparse storage technology is employed to enhance computational efficiency during the power flow calculation process. Comparative analysis with other algorithms is conducted to demonstrate the effectiveness of the proposed algorithm. Finally, the proposed algorithm and model are simulated and analyzed using the improved IEEE39 node system to verify the feasibility of the proposed strategy.