Looking at the picture, your algorithm is quite simple. find Doji candles and calculate low, higher according to those levels! This algorithm also has to calculate the limit of the number of bars that need to be determined. Please chat with me for advice