Using Monte Carlo generators of the PYTHIA model for hadron-hadron collisions and a multiphase transport (AMPT) model for nucleus-nucleus collisions, the longitudinal boost invariance of charge balance function and its transverse-momentum dependence are carefully studied. It shows that the charge balance function is boost invariant in both p+p and Au+Au collisions in these two models, consistent with experimental data. The balance function properly scaled by the width of the pseudorapidity window is independent of the position or the size of the window and is corresponding to the balance funct...