OPEN-SOURCE SCRIPT
更新済 Engulfing Zone [8 Types]

Engulfing Zone [8 Types]
A price action tool that scans closed candles for engulfing behavior and draws the exact zone
each pattern creates, from the candle that sets the level to the candle that breaks it.
Instead of treating "engulfing" as one generic signal, this script separates it into eight
distinct types and reports every pattern under exactly one of them, so what you see on the
chart is never double counted.
WHAT MAKES THIS DIFFERENT FROM A STANDARD ENGULFING INDICATOR
1. Engulfing is measured by the CLOSE, not by body overlap.
Most engulfing scripts check whether one candle's body covers the previous candle's body.
This script requires the Confirm candle to CLOSE beyond the Base candle's High or Low, wick
included. A candle that merely covers the body but closes back inside the Base range is not
accepted. This is a stricter definition and it filters out a large number of weak signals that
body based detection would report.
2. Confirmation is allowed to be delayed.
A classic engulfing pattern is strictly two candles. In real markets the reaction is often
spread over several candles: a base forms, price pushes in the opposite direction for a few
bars, and only then does a close break the base level. This script detects those extended
setups as their own category rather than ignoring them.
3. Liquidity sweeps are identified as a separate class.
Sometimes the candles that produce the engulf first trade through the far side of the Base
candle, taking out the stop orders resting there, and only then close through the opposite
side. That behavior is meaningfully different from a clean engulf, so it is detected and
labelled separately as Type 1.
THE EIGHT PATTERNS
Throughout, a candle is Green when close is greater than open, Red when close is less than
open, and a Doji when close equals open. A Doji is neither Green nor Red, and is handled
explicitly. Only fully closed candles are read. The running candle is never used.
Regular (2 candles)
R Buy EG
R Sell EG
E-Regular (3 or more candles)
ER Buy EG
ER Sell EG
If the very first candle after the Base already closes through it, that is by definition a
Regular pattern, so E-Regular requires the second candle or later to be the one that breaks
the level. Regular and E-Regular can therefore never both fire from the same Base candle.
Type 1: the same four patterns plus a liquidity sweep
Type 1 adds one requirement on top of the rules above. Before the close breaks through one
side of the Base candle, price must have traded through the opposite side.
T1 R Buy EG
An R Buy EG where the Confirm candle's Low is at or below the Base candle's Low.
T1 R Sell EG
An R Sell EG where the Confirm candle's High is at or above the Base candle's High.
T1 ER Buy EG
An ER Buy EG where at least one Green candle in the run has a Low at or below the Base
candle's Low. Any candle of the run qualifies, including the Confirm candle itself.
T1 ER Sell EG
An ER Sell EG where at least one Red candle in the run has a High at or above the Base
candle's High. Any candle of the run qualifies, including the Confirm candle itself.
The sweep is always measured against the Base candle, never against another candle in the run.
HOW A PATTERN IS CLASSIFIED
Every detected pattern is reported once, under its strongest matching type.
A Regular pattern that also swept is reported as T1 R and is not additionally reported as R.
An E-Regular pattern that also swept is reported as T1 ER and is not additionally reported as
ER. This means:
Because Type 1 is a stricter version of its plain counterpart, hiding the plain types and
keeping the Type 1 types visible is a straightforward way to see only the sweep driven setups.
READING THE CHART
Each detected pattern draws a rectangle covering the Base candle's full High to Low range,
stretched horizontally from the Base candle to the Confirm candle. The rectangle is styled so
that its type can be read without looking at the label:
Type 1 zones are also filled more solidly than plain zones, so stronger patterns stand out
when several zones sit close together.
On a Type 1 zone, a dotted line marks the exact Base level that was raided before the break:
the Base Low on the Buy side, the Base High on the Sell side. This makes the liquidity grab
visible instead of leaving it implied.
Each zone carries a label showing its pattern tag. Labels point at their own zone, below and
pointing up for Buy patterns, above and pointing down for Sell patterns, so it is always clear
which label belongs to which rectangle.
A summary table in the corner shows how many of each type were found inside the current scan
window, split into Buy and Sell columns. The table counts every detected pattern, including
types that are currently hidden, so it always reflects what the market actually printed rather
than what is currently switched on.
SETTINGS
Scan
Scan Length: how many closed candles are scanned backwards from the latest bar.
The running candle is always excluded.
Pattern Types
An individual on and off switch for each of the eight types.
Zone Style
- Bullish Zone and Bearish Zone: the two base colors used for all Buy and all Sell zones.
- Zone Transparency: fill transparency of a plain Regular or E-Regular zone.
- Type 1 Extra Opacity: how much more solid Type 1 zones are filled compared to the value
above.
- Mark Swept Level: draw the dotted line on the raided Base level of Type 1 zones.
- Swept Level Color: color of that line.
Labels
- Show Labels, Label Size, and Label Distance from Zone as a percentage of the Base candle
height. Increase the distance on noisy charts so labels clear the candles.
Summary Table
- Show, position, and size of the corner table.
ALERTS
Eight alert conditions are available, one per pattern type:
R Buy EG, R Sell EG, T1 R Buy EG, T1 R Sell EG, ER Buy EG, ER Sell EG, T1 ER Buy EG,
T1 ER Sell EG.
Each message carries the pattern tag, the symbol, the timeframe and the closing price. The
script also sends the same messages through the alert function, so the "Any alert() function
call" alert type can be used to receive every pattern through a single alert.
All alerts are evaluated only after a candle has fully closed.
REPAINTING
This script does not repaint.
- Detection reads confirmed candles only. The zone scan starts one bar behind the latest bar,
so the candle that is still forming is never part of any calculation.
- Every alert signal is written so that it can only become true once a candle has finished.
Price moving inside an open candle cannot make a signal appear and then disappear.
- Zones are rebuilt on the last bar using confirmed history. A zone that has been drawn does
not move or change type afterwards. It only leaves the chart when it falls outside the Scan
Length window.
When you create an alert, TradingView may show a caution banner saying the indicator can
repaint. That banner appears automatically for any script that uses the built in bar state
variables, no matter how they are used, because the platform cannot check the intent behind
them. This script uses them for the opposite purpose: one of them is what restricts every
signal to bar close, and the other is what redraws the zones efficiently on the final bar.
Choosing "Once Per Bar Close" when creating the alert is still recommended.
NOTES AND LIMITATIONS
- The script draws on the last bar only. Increasing Scan Length raises the number of drawing
objects. TradingView caps these at 500 boxes, 500 labels and 500 lines, and the oldest
objects are dropped once a cap is reached. The default value is chosen to stay well inside
those limits on normal charts.
- Detection is purely structural. It reports where a pattern occurred and nothing more. It
does not rank patterns by quality, measure follow through, or produce entries, targets or
stops.
- Doji candles are treated as neutral by design. They never act as a Base candle and never
break an E-Regular run. On symbols and timeframes that print many Doji candles this makes
runs slightly more tolerant than a strict same color rule would be.
HOW TO USE IT
The zones mark where one side of the market decisively lost control of a level. They are
reference areas, not entry signals on their own. Common approaches are to watch how price
behaves when it returns to a zone, or to use zone direction as context alongside higher
timeframe structure, support and resistance levels, or trend direction.
Type 1 zones deserve particular attention, because the sweep tells you the move happened after
liquidity was taken rather than before.
DISCLAIMER
This indicator is a pattern detection tool. It is not financial advice and it makes no claim
about profitability. Trading involves risk. Always apply your own analysis and risk management.
A price action tool that scans closed candles for engulfing behavior and draws the exact zone
each pattern creates, from the candle that sets the level to the candle that breaks it.
Instead of treating "engulfing" as one generic signal, this script separates it into eight
distinct types and reports every pattern under exactly one of them, so what you see on the
chart is never double counted.
WHAT MAKES THIS DIFFERENT FROM A STANDARD ENGULFING INDICATOR
1. Engulfing is measured by the CLOSE, not by body overlap.
Most engulfing scripts check whether one candle's body covers the previous candle's body.
This script requires the Confirm candle to CLOSE beyond the Base candle's High or Low, wick
included. A candle that merely covers the body but closes back inside the Base range is not
accepted. This is a stricter definition and it filters out a large number of weak signals that
body based detection would report.
2. Confirmation is allowed to be delayed.
A classic engulfing pattern is strictly two candles. In real markets the reaction is often
spread over several candles: a base forms, price pushes in the opposite direction for a few
bars, and only then does a close break the base level. This script detects those extended
setups as their own category rather than ignoring them.
3. Liquidity sweeps are identified as a separate class.
Sometimes the candles that produce the engulf first trade through the far side of the Base
candle, taking out the stop orders resting there, and only then close through the opposite
side. That behavior is meaningfully different from a clean engulf, so it is detected and
labelled separately as Type 1.
THE EIGHT PATTERNS
Throughout, a candle is Green when close is greater than open, Red when close is less than
open, and a Doji when close equals open. A Doji is neither Green nor Red, and is handled
explicitly. Only fully closed candles are read. The running candle is never used.
Regular (2 candles)
R Buy EG
- Base candle is Red
- The very next candle is Green
- That Green candle closes above the Base candle's High
R Sell EG
- Base candle is Green
- The very next candle is Red
- That Red candle closes below the Base candle's Low
E-Regular (3 or more candles)
ER Buy EG
- Base candle is Red
- It is followed by a run of consecutive Green candles
- The run must contain at least 2 Green candles
- Confirmation happens when one of those Green candles closes above the Base candle's High
- A single Red candle appearing before confirmation cancels the run entirely
- Doji candles are skipped: they neither count toward the run nor break it
ER Sell EG
- Base candle is Green
- It is followed by a run of consecutive Red candles
- The run must contain at least 2 Red candles
- Confirmation happens when one of those Red candles closes below the Base candle's Low
- A single Green candle appearing before confirmation cancels the run entirely
- Doji candles are skipped
If the very first candle after the Base already closes through it, that is by definition a
Regular pattern, so E-Regular requires the second candle or later to be the one that breaks
the level. Regular and E-Regular can therefore never both fire from the same Base candle.
Type 1: the same four patterns plus a liquidity sweep
Type 1 adds one requirement on top of the rules above. Before the close breaks through one
side of the Base candle, price must have traded through the opposite side.
T1 R Buy EG
An R Buy EG where the Confirm candle's Low is at or below the Base candle's Low.
T1 R Sell EG
An R Sell EG where the Confirm candle's High is at or above the Base candle's High.
T1 ER Buy EG
An ER Buy EG where at least one Green candle in the run has a Low at or below the Base
candle's Low. Any candle of the run qualifies, including the Confirm candle itself.
T1 ER Sell EG
An ER Sell EG where at least one Red candle in the run has a High at or above the Base
candle's High. Any candle of the run qualifies, including the Confirm candle itself.
The sweep is always measured against the Base candle, never against another candle in the run.
HOW A PATTERN IS CLASSIFIED
Every detected pattern is reported once, under its strongest matching type.
A Regular pattern that also swept is reported as T1 R and is not additionally reported as R.
An E-Regular pattern that also swept is reported as T1 ER and is not additionally reported as
ER. This means:
- One pattern produces exactly one zone on the chart, never two stacked on top of each other
- The summary table counts each pattern once
- Turning off a type hides only that type and never silently hides another
Because Type 1 is a stricter version of its plain counterpart, hiding the plain types and
keeping the Type 1 types visible is a straightforward way to see only the sweep driven setups.
READING THE CHART
Each detected pattern draws a rectangle covering the Base candle's full High to Low range,
stretched horizontally from the Base candle to the Confirm candle. The rectangle is styled so
that its type can be read without looking at the label:
- Solid border: Regular, confirmed by the very next candle
- Dashed border: E-Regular, confirmation was delayed over several candles
- Thin, softened border: a plain pattern, no sweep
- Thick, crisp border: Type 1, a liquidity sweep occurred
Type 1 zones are also filled more solidly than plain zones, so stronger patterns stand out
when several zones sit close together.
On a Type 1 zone, a dotted line marks the exact Base level that was raided before the break:
the Base Low on the Buy side, the Base High on the Sell side. This makes the liquidity grab
visible instead of leaving it implied.
Each zone carries a label showing its pattern tag. Labels point at their own zone, below and
pointing up for Buy patterns, above and pointing down for Sell patterns, so it is always clear
which label belongs to which rectangle.
A summary table in the corner shows how many of each type were found inside the current scan
window, split into Buy and Sell columns. The table counts every detected pattern, including
types that are currently hidden, so it always reflects what the market actually printed rather
than what is currently switched on.
SETTINGS
Scan
Scan Length: how many closed candles are scanned backwards from the latest bar.
The running candle is always excluded.
Pattern Types
An individual on and off switch for each of the eight types.
Zone Style
- Bullish Zone and Bearish Zone: the two base colors used for all Buy and all Sell zones.
- Zone Transparency: fill transparency of a plain Regular or E-Regular zone.
- Type 1 Extra Opacity: how much more solid Type 1 zones are filled compared to the value
above.
- Mark Swept Level: draw the dotted line on the raided Base level of Type 1 zones.
- Swept Level Color: color of that line.
Labels
- Show Labels, Label Size, and Label Distance from Zone as a percentage of the Base candle
height. Increase the distance on noisy charts so labels clear the candles.
Summary Table
- Show, position, and size of the corner table.
ALERTS
Eight alert conditions are available, one per pattern type:
R Buy EG, R Sell EG, T1 R Buy EG, T1 R Sell EG, ER Buy EG, ER Sell EG, T1 ER Buy EG,
T1 ER Sell EG.
Each message carries the pattern tag, the symbol, the timeframe and the closing price. The
script also sends the same messages through the alert function, so the "Any alert() function
call" alert type can be used to receive every pattern through a single alert.
All alerts are evaluated only after a candle has fully closed.
REPAINTING
This script does not repaint.
- Detection reads confirmed candles only. The zone scan starts one bar behind the latest bar,
so the candle that is still forming is never part of any calculation.
- Every alert signal is written so that it can only become true once a candle has finished.
Price moving inside an open candle cannot make a signal appear and then disappear.
- Zones are rebuilt on the last bar using confirmed history. A zone that has been drawn does
not move or change type afterwards. It only leaves the chart when it falls outside the Scan
Length window.
When you create an alert, TradingView may show a caution banner saying the indicator can
repaint. That banner appears automatically for any script that uses the built in bar state
variables, no matter how they are used, because the platform cannot check the intent behind
them. This script uses them for the opposite purpose: one of them is what restricts every
signal to bar close, and the other is what redraws the zones efficiently on the final bar.
Choosing "Once Per Bar Close" when creating the alert is still recommended.
NOTES AND LIMITATIONS
- The script draws on the last bar only. Increasing Scan Length raises the number of drawing
objects. TradingView caps these at 500 boxes, 500 labels and 500 lines, and the oldest
objects are dropped once a cap is reached. The default value is chosen to stay well inside
those limits on normal charts.
- Detection is purely structural. It reports where a pattern occurred and nothing more. It
does not rank patterns by quality, measure follow through, or produce entries, targets or
stops.
- Doji candles are treated as neutral by design. They never act as a Base candle and never
break an E-Regular run. On symbols and timeframes that print many Doji candles this makes
runs slightly more tolerant than a strict same color rule would be.
HOW TO USE IT
The zones mark where one side of the market decisively lost control of a level. They are
reference areas, not entry signals on their own. Common approaches are to watch how price
behaves when it returns to a zone, or to use zone direction as context alongside higher
timeframe structure, support and resistance levels, or trend direction.
Type 1 zones deserve particular attention, because the sweep tells you the move happened after
liquidity was taken rather than before.
DISCLAIMER
This indicator is a pattern detection tool. It is not financial advice and it makes no claim
about profitability. Trading involves risk. Always apply your own analysis and risk management.
リリースノート
Fixed an alert issue where a single Base candle could fire both a Regularand an E-Regular alert. Chart drawing was not affected. Alerts now match
the drawn zones exactly.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
Explore more trading tools & resources on my official website: rwbtradelab.com | Telegram: t.me/rwbtradelab
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
Explore more trading tools & resources on my official website: rwbtradelab.com | Telegram: t.me/rwbtradelab
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。