This indicator detects Engulfing Patterns with an ATR-based filtering mechanism and trend confirmation. Unlike a basic engulfing pattern indicator that only checks if a current candle engulfs the previous one, this script incorporates trend detection using either the 50-period SMA alone or a combination of 50 and 200-period SMAs to ensure that signals align with the broader trend. The indicator identifies Bullish Engulfing patterns when a strong bullish candle engulfs a smaller bearish candle in a downtrend and Bearish Engulfing patterns when a strong bearish candle engulfs a smaller bullish candle in an uptrend. It also generates alerts and visually marks these patterns with labels ("BU" for bullish and "BE" for bearish) while highlighting the background accordingly.
What sets this indicator apart from a normal engulfing indicator is its ATR-based filtering system, which ensures that only significant engulfing candles are considered. Instead of accepting any engulfing pattern, the script measures candle body size relative to 1.5x ATR (configurable) to filter out weak signals. It also differentiates between long-bodied and small-bodied candles to confirm that the engulfing pattern represents real momentum shifts. This approach reduces false signals caused by small, insignificant candles and ensures that traders focus on high-probability reversal patterns. By integrating trend-based filtering and ATR-based confirmation, this indicator provides more reliable and context-aware engulfing signals than a standard engulfing pattern detector.