Minimization of fast-ion losses induced by the 3D effects has been a topic of key importance in the context of controlling edge localized modes (ELMs) using resonant magnetic perturbations (RMPs). In this paper, numerical simulations have been carried out to explore the parameter space where ELM control and fast-ion confinement can be balanced. The ELM control capability, as represented by edge magnetic stochasticity, exhibits different dependencies on the RMP spectrum compared to fast-ion losses, thereby creating an optimization window. Selecting the optimal spectrum can reduce the fast-ion loss by a factor of two. Parameter scanning results reveal that the fast-ion loss is primarily attributed to global kink-like magnetic perturbations, which can be amplified by increased plasma pressure. In contrast, the edge magnetic stochasticity is strongly associated with the layer physics and influenced by plasma resistivity and rotation. This fundamental difference provides a basis for addressing the compatibility issue between the control effect and the minimization of fast-ion losses. The spectral dependencies of magnetic stochasticity and fast-ion losses respectively depict strong and negligible dependence on q95 within a narrow range, whereas on a larger scale, they exhibit similar linear variations. Applying high-n RMP represents a more effective strategy than low-n RMP in minimizing fast-ion loss. The results presented here may provide insights into the optimization of RMP configurations and plasma parameters with respect to the NBI confinement in future studies.