A bull flag
is essentially a small consolidation near the top of an upthrust. If we picture it as a candlestick
pattern, it should have a big green candlestick
+ a small body red/green candle near the top of the top big green candle.
This script essentially help you identify these.