This script helps identify valid pullbacks. Based on the marked pullbacks, it can draw both internal and external structure trendlines.
A pullback is marked with a small triangle above or below the candle that created the local high or low.
A new local high is marked with a red triangle above the candle if at least one subsequent candle has a low lower than the low of the candle that created the new local high.
A new local low is marked with a green triangle below the candle if at least one subsequent candle has a high higher than the high of the candle that created the new local low.
Based on the marked local highs and lows, the internal structure trendline is created by simply connecting all highs and lows with a line.
The external structure is drawn in a similar way, but only highs and lows that have broken the previous structure are connected. This helps focus on important pivots and better understand the market structure.