OPEN-SOURCE SCRIPT
Engulfing Candles (ATR-Based) with Volume Spike

Overview:
This script is designed to detect high-probability bullish and bearish engulfing patterns — but with a twist: it filters them through ATR-based volatility and confirms strength with volume spikes, all while offering optional trend filtering. It's built for traders who want more than just surface-level candle patterns — it's for those who want contextual confirmation before entering a trade.
What Makes It Different:
Most engulfing candle indicators simply match two candle shapes. This script goes deeper by:
Measuring candle body size relative to recent volatility (via ATR).
Checking for volume confirmation using a dynamic spike threshold.
Filtering based on trend context using SMA-based structure detection.
This tri-layered logic aims to avoid false positives and give traders cleaner, more actionable entries that align with momentum.
Core Concepts:
1. Trend Detection (Optional)
You can choose between two structural filters:
SMA50 only: Looks for price above or below the 50-period SMA to define trend direction.
SMA50 + SMA200 alignment: A stricter rule requiring both fast and slow SMAs to confirm a trend.
Or turn off trend filtering entirely (No detection).
This helps ensure engulfing setups appear in line with the broader trend, increasing the likelihood of continuation.
2. ATR-Filtered Candle Bodies
To eliminate noise:
A candle is only considered a valid engulfing candle if it has a body larger than 1.5× ATR(14).
The previous candle must be a small-bodied candle (less than 0.5× ATR), creating a clear visual engulfing structure.
This method dynamically adjusts for market volatility, so setups are meaningful even during periods of compression or expansion.
3. Volume Spike Confirmation
Not all engulfing candles lead to follow-through. That’s why this script includes a volume confirmation filter:
A 20-period moving average of volume is calculated.
A spike is flagged if the current bar’s volume exceeds 1.5× this average (adjustable).
Patterns with this confirmation are marked with a “*” label (e.g., BU* or BE*) to distinguish volume-backed setups from weaker ones.
Visuals & Alerts:
BU = Bullish engulfing without volume spike
BU* = Bullish engulfing with volume spike
BE = Bearish engulfing without volume spike
BE* = Bearish engulfing with volume spike
A white background highlight is shown behind candles with volume-confirmed engulfing patterns.
Alerts are available for BU* and BE* so you can automate your edge.
How to Use:
Add the indicator to any chart.
Choose your trend filter from the settings panel.
Watch for BU* and BE* labels — these are your highest-conviction signals.
Optional: Combine with support/resistance, Fibonacci zones, or MTF confirmation to refine entries.
Use the included alerts to receive real-time push/email notifications when patterns emerge.
Performance Note:
I’ve found this script to be fairly good when applied to the 1-hour charts of the companies in the US100. The combination of ATR-based filtering and volume confirmation appears to provide clear, high-quality setups with good follow-through potential.
By blending candle patterns, volatility filtering, volume confirmation, and trend context, this script aims to filter out weak signals and highlight the most statistically significant engulfing opportunities.
This script is designed to detect high-probability bullish and bearish engulfing patterns — but with a twist: it filters them through ATR-based volatility and confirms strength with volume spikes, all while offering optional trend filtering. It's built for traders who want more than just surface-level candle patterns — it's for those who want contextual confirmation before entering a trade.
What Makes It Different:
Most engulfing candle indicators simply match two candle shapes. This script goes deeper by:
Measuring candle body size relative to recent volatility (via ATR).
Checking for volume confirmation using a dynamic spike threshold.
Filtering based on trend context using SMA-based structure detection.
This tri-layered logic aims to avoid false positives and give traders cleaner, more actionable entries that align with momentum.
Core Concepts:
1. Trend Detection (Optional)
You can choose between two structural filters:
SMA50 only: Looks for price above or below the 50-period SMA to define trend direction.
SMA50 + SMA200 alignment: A stricter rule requiring both fast and slow SMAs to confirm a trend.
Or turn off trend filtering entirely (No detection).
This helps ensure engulfing setups appear in line with the broader trend, increasing the likelihood of continuation.
2. ATR-Filtered Candle Bodies
To eliminate noise:
A candle is only considered a valid engulfing candle if it has a body larger than 1.5× ATR(14).
The previous candle must be a small-bodied candle (less than 0.5× ATR), creating a clear visual engulfing structure.
This method dynamically adjusts for market volatility, so setups are meaningful even during periods of compression or expansion.
3. Volume Spike Confirmation
Not all engulfing candles lead to follow-through. That’s why this script includes a volume confirmation filter:
A 20-period moving average of volume is calculated.
A spike is flagged if the current bar’s volume exceeds 1.5× this average (adjustable).
Patterns with this confirmation are marked with a “*” label (e.g., BU* or BE*) to distinguish volume-backed setups from weaker ones.
Visuals & Alerts:
BU = Bullish engulfing without volume spike
BU* = Bullish engulfing with volume spike
BE = Bearish engulfing without volume spike
BE* = Bearish engulfing with volume spike
A white background highlight is shown behind candles with volume-confirmed engulfing patterns.
Alerts are available for BU* and BE* so you can automate your edge.
How to Use:
Add the indicator to any chart.
Choose your trend filter from the settings panel.
Watch for BU* and BE* labels — these are your highest-conviction signals.
Optional: Combine with support/resistance, Fibonacci zones, or MTF confirmation to refine entries.
Use the included alerts to receive real-time push/email notifications when patterns emerge.
Performance Note:
I’ve found this script to be fairly good when applied to the 1-hour charts of the companies in the US100. The combination of ATR-based filtering and volume confirmation appears to provide clear, high-quality setups with good follow-through potential.
By blending candle patterns, volatility filtering, volume confirmation, and trend context, this script aims to filter out weak signals and highlight the most statistically significant engulfing opportunities.
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。