We present an algorithm termed COMPEL (COnstant Molecular Pressure with Ewald sum for Long range forces) to conduct simulations in the NPT ensemble. The algorithm combines novel features recently proposed in the literature to obtain a highly efficient and accurate numerical integrator. COMPEL exploits the concepts of molecular pressure, rapid stochastic relaxation to equilibrium, exact calculation of the contribution to the pressure of long-range nonbonded forces with Ewald summation, and the use of Trotter expansion to generate a robust, highly stable, symmetric, and accurate algorithm. Explicit implementation in the MOIL program and illustrative numerical examples are discussed.