This script looks at 4 candles at a time.
If the first 3 candles in the pattern are BEARISH and the 4th candle BULLISH engulfs the 3rd candle then a GREEN triangle UP will display BELOW the 4th candle
If the first 3 candles in the pattern are BULLISH and the 4th candle BEARISH engulfs the 3rd candle then a RED triangle DOWN will display ABOVE the 4th candle