We propose a new algorithm to detect and classify transient cardiac ischemia episodes, designed with the goal of providing a real-time execution without penalizing the classifier accuracy much. The algorithm is based on a novel mixture of time-domain analysis and machine learning techniques, specifically bagging of decision trees, and it has been developed using a well-recognized and freely distributed database, namely the long-term ST database. The ST episode detection sensitivity/positive predictivity using the annotation protocol A for this database is 68.26%/74.91%. The sensitivity result increases until 93.97% for the most dangerous episodes in terms of duration and magnitude (annotated according to protocol C). The test of the algorithm over the freely distributed part of the European Society of Cardiology database has shown results of sensitivity and positive predictivity of 83.33% and 77.31%, respectively. Those results are close to the results obtained by related works that present approaches to detect ischemia episodes off-line, which is remarkable if we take into account that in our real-time approach, less information is available during the classification process.