The ALPHA collaboration has successfully demonstrated the production and the confinement of cold antihydrogen, $\overline{\mathrm{H}}$. An analysis of trapping data allowed a stringent limit to be placed on the electric charge of the simplest antiatom. Charge neutrality of matter is known to a very high precision, hence a neutrality limit of $\overline{\mathrm{H}}$ provides a test of CPT invariance. The experimental technique is based on the measurement of the deflection of putatively charged $\overline{\mathrm{H}}$ in an electric field. The tendency for trapped $\overline{\mathrm{H}}$ atoms to be displaced by electrostatic fields is measured and compared to the results of a detailed simulation of $\overline{\mathrm{H}}$ dynamics in the trap. An extensive survey of the systematic errors is performed, with particular attention to those due to the silicon vertex detector, which is the device used to determine the $\overline{\mathrm{H}}$ annihilation position. The limit obtained on the charge of the $\overline{\mathrm{H}}$ atom is \mbox{$ Q = (-1.3\pm1.8\pm0.4)\times10^{-8}$}, representing the first precision measurement with $\overline{\mathrm{H}}$.