In this study, an algorithm autodetection of PPG (Photoplethysmography) and ECG in an electrocardiogram is proposed. Many researches have been done for developing a new approach in this field, using different algorithms ranging from filtering and threshold methods, through wavelet methods, to neural networks, and others, each of which has different effectiveness and weaknesses. Although their performance in general good, but, the main weakness is that they are threshold dependent. Threshold-free detection is another proposed algorithm, where RR moving interval is calculated based on normal maximum and minimum heart rate (HR). This has the advantage of ensuring that every R-peak is contained between the edges of the moving interval. Thus, the effectiveness of this algorithm is that it is threshold independent, but its weaknesses are in the change in the RR interval according to the change in the heart rate frequency, which leads to missing some peaks. The effectiveness of the new algorithm autodetection peak is developed to overcome the weaknesses of threshold dependent and threshold independent algorithms. It based on a threshold-free algorithm with double moving windows. The complete algorithm is implemented using MATLAB 7.4. The method is validated using 18 recorded signals. The average sensitivity and average positive predictivity of PPG are 99.5% and 99.6% and of ECG are 99.3% and 99.4% respectively.