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.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.