This paper presents a stress detection algorithm using heart rate variability (HRV) parameters. Five-minute electrocardiograms were recorded at rest and under exam stress (252 students were involved). The determined HRV parameters were applied to detect stress by means of several classification algorithms. We analysed linear indices in the time (standard deviation of NN intervals (SDNN) and root mean square of successive RR interval differences (RMSSD)) and frequency domains (low frequency (LF) and high frequency (HF) power as well as LF/HF ratio). To study nonlinear HRV indices, we evaluated approximate entropy (ApEn), sample entropy (SampEn), α1 (DFA1) and α2 (DFA2) scaling exponents, correlation dimension D2, and recurrence plot quantification measures (recurrence rate (REC), mean diagonal line length (Lmean), maximum diagonal line length (Lmax), determinism (DET), and Shannon entropy (ShanEn)). Receiver operating characteristic (ROC) was used to test the performance of the classifiers derived from HRV. The highest area under the ROC curve (AUC), sensitivity, and specificity were found for mean RR-interval, DFA1, DFA2, RMSSD, and Lmax. These parameters were used for stress/rest classification with the help of algorithms that are common in clinical and physiological applications, i.e. logistic regression (LR) and linear discriminant analysis (LDA). Classification performance for stress was quantified using accuracy, sensitivity and specificity measures. The LR achieved an accuracy of 68.25 % at an optimal cutoff value of 0.57. LDA determined stress with 67.46 % accuracy. Thus, HRV parameters can serve as an objective tool for stress detection.