Master Candle's Trendlines until it's broken
here is a picture of what I have now :
- (H1) ranges and master ranges are already calculated.
- the white trend lines are made by hand.
How can i draw the trend lines and stop drawing it when the price have broken the high OR the low ?
regards.

i am writing a "Master Candle" indicator (on H1).
Master candles are highlighted, but now, i need to draw high and low trend lines until the price break these high or low.
Then the trendline are stopped to be drawn on the (H1) candle breakout.
How can i do that please ?
Here is my code :
Regards.