Indicator TutorialPine Script v6

Choosing an Engulfing Candle Indicator on TradingView

Compare body rules, trend filters, and alert timing before choosing a detector.

For standard engulfing labels, start with TradingView's built-in Engulfing indicators. For custom body-size, wick, or volume rules, use the editable Pine Script below. There is no demonstrated universal best indicator here: this guide compares definitions and controls, not trading returns. A bullish engulfing pattern covers the previous bearish body; it does not have to cover both wicks.

Built-in, Community, or Custom Engulfing Indicator?

In TradingView, open Indicators, metrics, and strategies → Technicals → Patterns and find Engulfing - Bullish or its bearish counterpart. This is the built-in route for adding pattern labels and creating alerts. See TradingView's candlestick detection instructions.

  • Built-in detector: Use it when you want the documented pattern and trend settings. TradingView's bullish detector offers SMA50, SMA50/SMA200, or no trend detection.
  • Community script: Check the author's definition, accessible source, confirmation timing, and alert support. Popularity alone does not establish predictive performance.
  • Custom detector: Use the example below when you need explicit equality rules, optional full-range engulfing, or adjustable filters. Its defaults are illustrative and have not been optimized or backtested.

A bullish engulfing formation is usually interpreted after a decline. TradingView's Engulfing - Bullish definition requires body coverage, not full high-to-low coverage. An opposite-colored pair elsewhere on the chart still meets a geometric rule, but does not establish a reversal.

Compare other TradingView indicators or browse the TradingView guides for related setup tasks.

Why Traders Use This Indicator

  • Apply the same body-coverage rule to each pair of candles.
  • Separate basic pattern geometry from optional volume, wick, and trend filters.
  • Mark confirmed patterns and create separate bullish and bearish alerts.
ParameterDefaultDescription
Minimum Body Ratio1.1Current body must be at least 1.1 times the prior body. This is an example threshold, not an optimal setting.
Require Wick EngulfingOffWhen enabled, the current high must reach the prior high and the current low must reach the prior low.
Rejection Wick FilterOn; 0.35Bullish upper wick or bearish lower wick must be no more than 35% of the current body. Disable to inspect unfiltered geometry.
Volume FilterOff; SMA 20When enabled, volume must exceed its current 20-bar SMA. Missing volume or insufficient history blocks the filtered signal.
Trend Continuation FilterOff; EMA 200When enabled, bullish closes must be above the EMA and bearish closes below it. This is different from looking for a reversal after an opposing trend.

Body Rules, Wick Rules, and Examples

The example uses inclusive body boundaries. A bullish pair requires close[1] < open[1], close > open, open <= close[1], and close >= open[1]. A bearish pair reverses those inequalities. Equal opens and prior closes are allowed; dojis are excluded by the direction checks.

Body size is math.abs(close - open). Upper wick is high - math.max(open, close); lower wick is math.min(open, close) - low. Full-range engulfing additionally requires high >= high[1] and low <= low[1]. This optional rule is stricter than body coverage.

  • Bullish positive example: Previous O/H/L/C = 102/103/99/100; current = 100/103/99.5/102.5. The 2.5-point body covers the previous 2-point body. Its upper wick is 0.5, so it passes the default ratio and wick cap. It fails full-range engulfing because 99.5 is above the prior low of 99.
  • Body-coverage counterexample: Keep the previous candle and change the current close to 101.8. A green candle is present, but it does not reach the previous open of 102, so it is not bullish engulfing.
  • Wick-only counterexample: Current O/H/L/C = 100.5/104/98/101.5. Its range encloses the prior range, but its body covers neither body boundary. An outside bar is not automatically an engulfing body.
  • Bearish positive example: Previous O/H/L/C = 100/103/99/102; current = 102/103/99/99.5. The red body covers the green body and passes the default body and lower-wick filters.

These are constructed OHLC examples for checking rules, not observed trades or performance results. Confirmation and any enabled filters must also pass.

Signal Interpretation

The code waits for barstate.isconfirmed before drawing a marker or enabling an alert condition. On an open candle, the close and wick sizes can change. Waiting for the close avoids provisional markers from those updates; it does not prove that a subsequent reversal will occur. See TradingView's bar-state documentation.

A pattern is an observation, not an order. This indicator has no entries, exits, stop-loss execution, or Strategy Tester results. If you use the two-bar low or high as an invalidation reference, define the actual exit and fill assumptions separately.

For setup details, see the official Pine alerts documentation. Multi-symbol discovery uses separate screener pattern rules.

Combining with Other Indicators

Trend context changes the question being asked. A reversal study can require a preceding decline before a bullish pair. The optional EMA filter in this example instead selects bullish closes above the EMA and bearish closes below it. It does not measure a preceding pullback or EMA slope.

Volume above its moving average is a measurable filter, but does not identify who traded or guarantee better signals. Missing or feed-specific volume can make comparisons unreliable. Add RSI, volume, or support conditions one at a time and evaluate a separate period before retaining them.

Writing Pine Script Manually

Challenges of Manual Coding

Specify whether equal body boundaries count and whether the wicks also need to be covered.

Use the same confirmed signal for chart markers and alert conditions.

Explain how missing volume and filter warm-up affect signals.

Keep reversal context distinct from a trend-continuation filter.

Pine Script v6
//@version=6
indicator("Bullish & Bearish Engulfing Detector", shorttitle="Engulfing", overlay=true)

minBodyRatio = input.float(1.1, "Minimum Body Ratio", minval=1.0, step=0.1)
requireWicks = input.bool(false, "Require Wick Engulfing")
useWickFilter = input.bool(true, "Use Rejection Wick Filter")
maxWickRatio = input.float(0.35, "Maximum Rejection Wick / Body", minval=0.0, step=0.05)
useVolumeFilter = input.bool(false, "Use Volume Filter")
volumeLength = input.int(20, "Volume SMA Length", minval=1)
useTrendFilter = input.bool(false, "Use EMA Continuation Filter")
trendLength = input.int(200, "Trend EMA Length", minval=1)

body = math.abs(close - open)
previousBody = math.abs(close[1] - open[1])
upperWick = high - math.max(open, close)
lowerWick = math.min(open, close) - low
volumeMA = ta.sma(volume, volumeLength)
trendEMA = ta.ema(close, trendLength)

bodySizeOk = body >= previousBody * minBodyRatio
rangeOk = not requireWicks or (high >= high[1] and low <= low[1])
volumeOk = not useVolumeFilter or (not na(volume) and not na(volumeMA) and volume > volumeMA)
bullTrendOk = not useTrendFilter or close > trendEMA
bearTrendOk = not useTrendFilter or close < trendEMA
bullWickOk = not useWickFilter or upperWick <= body * maxWickRatio
bearWickOk = not useWickFilter or lowerWick <= body * maxWickRatio

bullBody = close[1] < open[1] and close > open and open <= close[1] and close >= open[1]
bearBody = close[1] > open[1] and close < open and open >= close[1] and close <= open[1]
bullSignal = barstate.isconfirmed and bullBody and bodySizeOk and rangeOk and volumeOk and bullTrendOk and bullWickOk
bearSignal = barstate.isconfirmed and bearBody and bodySizeOk and rangeOk and volumeOk and bearTrendOk and bearWickOk

plotshape(bullSignal, title="Bullish Engulfing", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small, text="Bull")
plotshape(bearSignal, title="Bearish Engulfing", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small, text="Bear")
plot(useTrendFilter ? trendEMA : na, title="Trend EMA", color=color.blue)

alertcondition(bullSignal, title="Bullish Engulfing Alert", message="Confirmed bullish engulfing on {{ticker}} at {{close}}")
alertcondition(bearSignal, title="Bearish Engulfing Alert", message="Confirmed bearish engulfing on {{ticker}} at {{close}}")

Maintenance Note: Use a standard candlestick chart to inspect actual OHLC values. This example uses the chart symbol and timeframe only. Create each alert in TradingView with Once Per Bar Close. After changing code, inputs, symbol, or timeframe, recreate the alert to use the new settings.

Build with Pineify Visual Editor

Pineify lets you configure supported indicators and export Pine Script. Available settings and plan requirements vary by indicator. Compare the generated rules with the example before using its signals.

FeatureManual Pine ScriptPineify Visual Editor
Pattern definitionEdit the visible body and wick conditions in this example.The Candlestick Patterns module exposes bullish and bearish engulfing outputs; its rules differ from this custom example.
Pattern displayChange plotshape calls and their conditions.Use the module's individual bullish and bearish pattern display controls.
Custom thresholdsAdjust the example inputs or edit its code.For this exact custom logic, use AI Coding Agent and review the generated script. The module does not expose these same ratio inputs.

Select existing candlestick pattern outputs in the Visual Editor.

Use AI Coding Agent to adapt a detector from written body, wick, and confirmation requirements.

Review exported code and compare its marks with the intended OHLC rules.

Step-by-Step Tutorial

1

Choose the existing module or custom logic

The Visual Editor includes Candlestick Patterns with bullish and bearish engulfing outputs. This module is marked as a paid feature; the example code on this page is available to copy.

2

Choose the pattern displays

Use the Bullish Engulfing and Bearish Engulfing display controls for the existing module. Inspect its generated conditions before comparing results with another detector.

3

Specify custom requirements when needed

For the body ratio, optional wick coverage, and confirmed signals shown here, give the full example to AI Coding Agent and describe any desired changes. Check its output rather than assuming it matches the built-in module.

4

Verify the result in TradingView

Add the generated script to a chart, inspect the examples against its rules, and create alerts only after choosing the final settings.

Trading Strategies & Pro Tips

Compare detectors using the same chart

Keep symbol, session, timeframe, date range, and chart type fixed. When two indicators disagree, check body equality, minimum size, wick rules, and trend settings before treating either as wrong.

Evaluate reversal context separately

Record whether a bullish pattern follows a decline and whether a bearish pattern follows a rise. The optional EMA continuation filter in the example is a different hypothesis and should be evaluated separately.

Separate detection from profitability

To study returns, define entries, exits, fees, slippage, position size, and an evaluation period. The detector alone cannot supply a win rate or identify the best trading strategy.

Common Mistakes to Avoid

  • Treating an outside bar with incomplete body coverage as an engulfing body.
  • Expecting built-in and custom indicators with different rules to produce identical marks.
  • Treating a high-volume bar as evidence of institutional participation.
  • Expecting existing alerts to adopt edited script settings automatically.
  • Assuming a chart indicator automatically scans a watchlist or executes trades.

Frequently Asked Questions

For standard pattern labels, start with the built-in Engulfing indicators. Choose a custom script if you need different body, wick, volume, or alert rules. This guide has not measured comparative returns, so it does not rank indicators by profitability.

No. Body engulfing covers the prior open-to-close range. Full-range engulfing also covers the prior high and low; it is an optional, stricter rule in this example.

An intrabar condition can change as the candle develops. This example gates both marks and alerts with barstate.isconfirmed, so it waits for the chart bar to close. That timing does not guarantee a profitable outcome.

Add the indicator to the chart, open Create Alert, select the script and one of its named engulfing conditions, and choose Once Per Bar Close. Alertcondition defines an event; it does not create a running alert. Recreate an alert after changing its script or settings.

TradingView documents an Engulfing - Bullish candlestick pattern in its screener. That uses the screener's own detection rules. The custom chart script here evaluates one chart symbol and does not automatically become a watchlist scanner.

No. The Visual Editor has an existing Candlestick Patterns module with its own definitions and display controls. Use AI Coding Agent for custom requirements such as the ratio and wick filters in this example, then review and test the result.

Build a Detector with Explicit Rules

  • Choose the existing Candlestick Patterns module or request custom code.
  • Review body coverage, confirmation timing, and alert conditions.
  • Check plan access for the paid pattern module before building.

Disclaimer: Trading involves significant risk. The indicators, code, and strategies provided are for educational purposes only and do not constitute financial advice. Past performance is not indicative of future results.