Zerodha Pi Scanner : Tradescript for Bullflag pattern.

CLOSE <= REF(CLOSE,1) AND REF(CLOSE,1) > REF(CLOSE,2) AND
REF(CLOSE,2) > REF(CLOSE,3) AND
REF(CLOSE,3) >= REF(CLOSE,4) AND
ABS((REF(HIGH,1) - REF(LOW,1))) >= ABS((REF(HIGH,3) - REF(LOW,3)) * 2 AND
DIP(14) > DIN(14) AND
REF(ADX(14),1) > REF(ADX(14),2) AND
REF(ADX(14),2) > REF(ADX(14),3) AND
REF(VOLUME,1) > REF(VOLUME,2) AND
REF(VOLUME,2) > REF(VOLUME,4) AND
REF(VOLUME,1) > REF(VOLUME,4) * 2

The above Pi Scanner Tradescript code will generate alert for Bull FLAG formation.
Alert is generated on the First candle after pole formation.

The below charts were identified on the  Pi Scanner.