The combined treatment of tumours in which delivery of a chemotherapeutic agent is followed by high voltage electroporation pulses has been termed electrochemotherapy. The electrochemotherapy of tumours located relatively close to the heart muscle can lead to fibrillation of the heart, especially if electroporation pulses are delivered in the vulnerable period of the heart or in coincidence with heart arrhythmias. We built an electroporation pulse delivery algorithm that enables safer use of electrochemotherapy. The algorithm is designed to deliver pulses outside the vulnerable period and to prevent pulses from being generated in the presence of heart arrhythmias. We evaluated the algorithm's performance using records of the Long-Term ST Database, thus simulating real-world conditions. The results of the evaluation, a sensitivity of 91.751%, a positive predictivity of 100.000% and a delivery error rate of 8.268% for electroporation pulse delivery (medians), suggest that the algorithm is accurate and appropriate for application in electrochemotherapy of tumours regardless of tumour location.