Here it is better to use candle "1" because candle "0" is also the market price, although not the middle one but it could be due to such a constellation.
Create the variable.
Do not use delete objects. That causes all of them to be deleted when price break any mark. You only want the ones deleted that price has broken so use the delete bloc under the loop for chart object section.
I don't think it's a bug or anything. Sometimes you have to tinker around with things to get it to work.