The influence of the internuclear distance and quantum dot size on the nonlinear optical rectification of a hydrogen molecular ion D-2(+) confined in a two-dimensional quantum dot was calculated. In the framework of the effective mass approximation, the solutions of the resulting eigenvalue equation are obtained using the two-dimensional diagonalization method. It was demonstrated that the nonlinear optical rectification of the D-2(+) complex shows a double-peak structure and a considerable increase in the peak value is seen by increasing the distance between nuclei. In addition, it has been determined that the nonlinear optical rectification amplitude is larger in large-sized QDs and in the case of high asymmetry of the system. Based on our calculations, it was shown that by adjusting the distance between nuclei, a redshift or blueshift at the peak position of the nonlinear optical rectification of the molecular complex can be achieved.