We present an algorithm for automatic on-line analysis of the electrocardiography (ECG) channel acquired during overnight polysomnography (PSG) studies. The system is independent of ECG morphology, requires no manual initialization, and operates automatically throughout the night. It highlights likely occurrences of arrhythmias and intervals of bad signal quality while outputting a continual estimate of heart rate. Algorithm performance is validated against standard ECG databases and PSG data. Results demonstrate a minimal false negative rate and a low false positive rate for arrhythmia detection, and robustness over a wide range of noise contamination.