Dosimetry with ionization chambers in clinical ion beams for radiation therapy requires correction for recombination effects. However, common radiation protocols discriminate between initial and general recombination and provide no universal correction method for the presence of both recombination types in ion beams of charged particles heavier than protons. Here, we present the open source code IonTracks, where the combined initial and general recombination effects in principle can be predicted for any ion beam with arbitrary particle-energy spectrum and temporal structure. IonTracks uses track structure theory to distribute the charge carriers in ion tracks. The charge carrier movements are governed by a pair of coupled differential equations, based on fundamental physical properties as charge carrier drift, diffusion, and recombination, which are solved numerically while the initial and general charge carrier recombination is computed.The algorithm is numerically stable and in accordance with experimentally validated theories for initial recombination in heavy ion tracks and general recombination in a proton beam.IonTracks is validated against the Jaffé's and Boag's theory of recombination in pulsed beams of multiple ion species. IonTracks is able to calculate the correction factor for initial and general recombination losses in parallel-plate ionization chambers. Even if only few experimental data on recombination effects in ionization chambers are available today, the universal concept of IonTracks is not limited to the ions investigated here. Future experimental investigations of recombination in pulsed and possibly also continuous ion beams may be conducted with IonTracks, which ultimately may lead to a more precise prediction of recombination factors in complex radiation fields.