Hidden Markov models (HMM) are useful tools to characterize the dynamics of observation sequences.However, the duration of the observation sequence to characterize is often chosen empirically, based on a priori information.In this paper, we used a grid search approach to optimize two hyperparameters of an HMM-based QRS complex detector, namely, the duration of the observation sequence to be characterized and the adaptive decision threshold that compares the difference of log-likelihoods of observations from two competing HMM.To assure the reproducibility of the results, we have run the optimization process ten times using different random seeds per realization.Using the ECG signals from the MIT-BIH Arrhythmia database, we have found an optimal adaptive decision threshold of 60% but the optimal value of the observation sequence duration varies from 100 ms to 120 ms for different realizations of the optimization process.Consequently, the different parameters of the HMM-based QRS complex detector found in each realization do not always lead to the same detection performance.Using the optimal values, the detector achieves a sensitivity of 96.53% and a positive predictivity of 98.16%.