The heart is the body"s circulatory organ that supplies blood to the body. An electrocardiogram is the best means of measuring and diagnosing abnormal conduction of the heart muscle. Therefore, to diagnose patients suspected of heart disease, a Holter monitoring system measuring electrocardiography for 24 hours is used by doctors to examine and diagnose patients. However, diagnosing innumerable Holter data entails considerable effort by doctors directly. If QRS can be detected by an automated diagnostic system, many Holter data could be classified without diagnosing it by clinicians directly. In this paper, we tried to detect the QRS of electrocardiogram using the Hidden Markov Model. For objective verification, the onsets and offsets of QRS, which classified by the specialist, in the QT-database, were used as the reference labels. The Mexican Hat mother function was used for the wavelet transform. To study how to optimize the learning of hidden Markov models, the experiment was conducted by changing the batch size of the training data sets and the scale of the wavelet mother function. During the verification process, the mean and standard deviation of the difference between QRS onset and offset obtained from the test data sets through the hidden Markov model and the reference label classified by a specialist were used. As a result, the batch size was found to have the best performance using all 84 training data sets, and the scale of the mother function was found to have the best performance using scale j = 2, 3, 4. When the mean and standard deviation of QRS complexes detected from the hidden Markov model was -8.2822ms, ±5.821476ms(p=0.99818) onsets, respectively and -2.9588ms, ±6.5662ms(p=0.99838) offsets, respectively with 84 batch sizes and all three scale mother functions were trained, the results of onset, offset standard deviation were improved average about 22.1%, 30.9% respectively when compared with other algorithms using QT-Database