OPEN-SOURCE SCRIPT
Pivot Consolidation Zone

█ OVERVIEW
Pivot Consolidation Zone detects consolidation ranges built between a confirmed pivot high and a confirmed pivot low. A zone is only created once both pivots have been tested and the pair satisfies a set of conditions: time distance, continuity of closes, and an optional height limit relative to ATR.
Once a zone is created, the indicator tracks its development and builds a Volume Profile for the range between the pivot high and pivot low. The profile shows the distribution of volume across price levels, along with an approximate Buy/Sell Volume split.
A close outside the zone ends the zone's activity and can generate a bullish or bearish signal. An optional Volume Confirmation filter requires the breakout direction to agree with the dominant volume side accumulated inside the zone before the breakout candle.
After a breakout, the zone is closed regardless of whether Volume Confirmation is met — the filter only determines whether a confirmed signal (and the zone recolor) is generated, not whether the zone ends. An optional TP/SL module can then plot Entry, Stop Loss, and up to three Take Profit levels, based on ATR or a fixed percentage and a chosen Risk:Reward.
█ CONCEPTS
The indicator combines pivot structure, the consolidation range, tests of the pivot candles, volume distribution, and breakout detection. A pivot on its own does not create a zone — a paired upper and lower pivot, a test on both sides, and price behavior inside the resulting range are all required.
Pivot Structure
A confirmed pivot high and pivot low mark the potential boundaries of a future zone. Pivot Length is the number of candles required on both sides of a local high or low to confirm it.
The zone's upper boundary is the pivot high price, and the lower boundary is the pivot low price. These two levels define the box and should not be confused with a test (see "Pivot Tests" below).
Pivot Pair
A zone is only created from a pair that satisfies all of the following conditions at once:
• the pivot high sits above the pivot low,
• both pivots fall within Max Pivot Pair Distance,
• closes between the start of the pair and the current candle stay inside the resulting range,
• the pair's height passes the optional ATR limit.
Max Pivot Pair Distance limits how far apart in time the pivots forming a single zone can be. This prevents distant price extremes from being automatically merged into one wide range.
Zone Range
Once a valid pair is found, the indicator draws a box:
• Top — the pivot high,
• Bottom — the pivot low,
• Left — extends backward as long as closes stay inside the range, up to a maximum of Max Box Left Edge bars,
• Right — advances with each new candle for as long as the zone remains active.
An optional ATR filter rejects pairs whose height exceeds a specified multiple of ATR.
Pivot Tests
A test does not refer to a touch of the finished zone's boundary. It refers only to the range of the candle that formed a given pivot.
For a pivot high, the indicator stores the range from that candle's high down to its low. For a pivot low, it stores the range from that candle's low up to its high. A test is recorded whenever a later candle overlaps this stored range.
Both pivots must accumulate at least one such test before the pair can form a zone. Optional markers show:
• ▼ — the pivot high candle,
• ▲ — the pivot low candle,
• numbered labels — successive tests of that pivot candle's range.
Numbering runs separately for the upper and lower pivot. These markers document the history that preceded the zone's formation, not subsequent touches of the already-drawn box.
ATR Breakout Margin
Min Breakout Size (x ATR) sets how far a close must move beyond a level to be treated as a breakout:
ATR × Min Breakout Size
A value of 0 disables the filter. The same margin is used to invalidate pivots, to check the continuity of the range, and to detect the zone breakout itself, so minor violations can be treated as noise.
Volume Profile
For an active zone, the range's height is divided into Price Bins. Each candle's volume is distributed across the bins according to how much of its high-low range overlaps each price level, then split into Buy and Sell Volume based on where the candle's close sits within that range:
• a close nearer the high increases the Buy Volume share,
• a close nearer the low increases the Sell Volume share.
The width of the strongest bin corresponds to Max Profile Width, and the remaining bins are scaled proportionally to it. The profile therefore shows both where volume concentrated and its approximate directional split.
By default, only the portion of a candle inside the zone is counted. Include Wick Volume Outside the Zone also adds volume from wicks extending beyond the range, assigning the excess to the nearest edge bin. This setting affects the profile, the Buy/Sell bars, the percentage label, and Volume Confirmation.
Buy/Sell Volume Split
Below the zone, two bars and a label can show the Buy/Sell Volume split for the entire range. The dominant side is:
• Buy — when Buy Volume is greater than or equal to Sell Volume,
• Sell — when Sell Volume is greater than Buy Volume.
Breakout
A zone ends when price closes outside its range:
• Breakout Up — Close > Zone Top + ATR margin,
• Breakout Down — Close < Zone Bottom − ATR margin.
If Volume Confirmation is disabled, the signal direction depends only on the breakout side. If enabled, a bullish breakout requires Buy Volume to be dominant, and a bearish breakout requires Sell Volume to be dominant.
The breakout candle is not added to the profile before this evaluation, so the breakout impulse itself cannot inflate the side that is confirming its own exit from the zone.
After a confirmed breakout, Recolor Zone on Breakout can change the box color to bullish or bearish. If the breakout is not confirmed, the zone stays neutral in color but is still closed.
TP/SL
After a confirmed signal, the TP/SL module plots Entry at the close of the breakout candle, a Stop Loss, and up to three targets. SL can be calculated as ATR × multiplier or as a fixed percentage from Entry. TP levels are derived from the chosen Risk:Reward ratios applied to the Entry-SL distance.
A new signal replaces the previous set of levels. The lines extend with price and stop once the market reaches the SL or the highest enabled TP. This is a level-planning tool, not an assessment of entry quality.
█ FEATURES
• Zone detection from a tested pivot high/pivot low pair, with a time-distance limit, close continuity check, and an optional ATR height limit.
• Volume Profile inside the zone, split into Price Bins with Buy and Sell Volume.
• Optional inclusion of wick volume extending outside the zone.
• Bars and label showing the total Buy/Sell Volume split below the zone.
• Upside and downside breakout signals, with optional Volume Confirmation.
• Zone recoloring on a confirmed breakout.
• Optional markers for pivot candles and numbered tests of their range.
• TP/SL module: Entry, SL, and TP1-TP3 based on ATR or percentage, and Risk:Reward.
• Alerts for upside and downside breakouts.
█ APPLICATIONS
Consolidation Analysis
The indicator locates ranges where price stays between a confirmed and tested pivot high and pivot low, producing a structure anchored to specific swing candles instead of a manually drawn box.
Zone Strength and Volume
The Volume Profile shows which price levels accumulated the most volume. The Buy/Sell split adds context on which side held the advantage across the whole range, not just at the moment of breakout.
Breakout Analysis
A signal marks price leaving the zone on a close outside its range. Volume Confirmation can narrow this down to breakouts that align with the volume split accumulated beforehand.
Example of Use
An active zone is better treated as an area of equilibrium than as a ready-made entry. Before acting on a signal, it helps to weigh:
• the breakout side,
• the dominant Buy/Sell Volume,
• the shape of the Volume Profile,
• the zone's position within the broader structure,
• momentum and context from a higher timeframe.
The zone being drawn, or a triangle appearing, is not on its own a sufficient reason to trade.
█ NOTES
• A test refers to the range of the pivot candle, not to a touch of the already-formed zone boundary.
• Volume Confirmation is optional. Without it, the signal depends only on the breakout direction.
• The breakout candle is excluded from the Volume Profile until after Volume Confirmation is evaluated.
• Buy and Sell Volume are derived from where the close sits within each candle's range. This is an estimate, not actual tape/order-flow buy/sell data.
• Show Breakout Signals is a shared switch: disabling it also disables the TP/SL module and the alerts, not just the on-chart triangles.
• TP/SL is a visual level-planning tool and does not assess the quality of a signal.
• This indicator does not replace independent market analysis or risk management.
Pivot Consolidation Zone detects consolidation ranges built between a confirmed pivot high and a confirmed pivot low. A zone is only created once both pivots have been tested and the pair satisfies a set of conditions: time distance, continuity of closes, and an optional height limit relative to ATR.
Once a zone is created, the indicator tracks its development and builds a Volume Profile for the range between the pivot high and pivot low. The profile shows the distribution of volume across price levels, along with an approximate Buy/Sell Volume split.
A close outside the zone ends the zone's activity and can generate a bullish or bearish signal. An optional Volume Confirmation filter requires the breakout direction to agree with the dominant volume side accumulated inside the zone before the breakout candle.
After a breakout, the zone is closed regardless of whether Volume Confirmation is met — the filter only determines whether a confirmed signal (and the zone recolor) is generated, not whether the zone ends. An optional TP/SL module can then plot Entry, Stop Loss, and up to three Take Profit levels, based on ATR or a fixed percentage and a chosen Risk:Reward.
█ CONCEPTS
The indicator combines pivot structure, the consolidation range, tests of the pivot candles, volume distribution, and breakout detection. A pivot on its own does not create a zone — a paired upper and lower pivot, a test on both sides, and price behavior inside the resulting range are all required.
Pivot Structure
A confirmed pivot high and pivot low mark the potential boundaries of a future zone. Pivot Length is the number of candles required on both sides of a local high or low to confirm it.
The zone's upper boundary is the pivot high price, and the lower boundary is the pivot low price. These two levels define the box and should not be confused with a test (see "Pivot Tests" below).
Pivot Pair
A zone is only created from a pair that satisfies all of the following conditions at once:
• the pivot high sits above the pivot low,
• both pivots fall within Max Pivot Pair Distance,
• closes between the start of the pair and the current candle stay inside the resulting range,
• the pair's height passes the optional ATR limit.
Max Pivot Pair Distance limits how far apart in time the pivots forming a single zone can be. This prevents distant price extremes from being automatically merged into one wide range.
Zone Range
Once a valid pair is found, the indicator draws a box:
• Top — the pivot high,
• Bottom — the pivot low,
• Left — extends backward as long as closes stay inside the range, up to a maximum of Max Box Left Edge bars,
• Right — advances with each new candle for as long as the zone remains active.
An optional ATR filter rejects pairs whose height exceeds a specified multiple of ATR.
Pivot Tests
A test does not refer to a touch of the finished zone's boundary. It refers only to the range of the candle that formed a given pivot.
For a pivot high, the indicator stores the range from that candle's high down to its low. For a pivot low, it stores the range from that candle's low up to its high. A test is recorded whenever a later candle overlaps this stored range.
Both pivots must accumulate at least one such test before the pair can form a zone. Optional markers show:
• ▼ — the pivot high candle,
• ▲ — the pivot low candle,
• numbered labels — successive tests of that pivot candle's range.
Numbering runs separately for the upper and lower pivot. These markers document the history that preceded the zone's formation, not subsequent touches of the already-drawn box.
ATR Breakout Margin
Min Breakout Size (x ATR) sets how far a close must move beyond a level to be treated as a breakout:
ATR × Min Breakout Size
A value of 0 disables the filter. The same margin is used to invalidate pivots, to check the continuity of the range, and to detect the zone breakout itself, so minor violations can be treated as noise.
Volume Profile
For an active zone, the range's height is divided into Price Bins. Each candle's volume is distributed across the bins according to how much of its high-low range overlaps each price level, then split into Buy and Sell Volume based on where the candle's close sits within that range:
• a close nearer the high increases the Buy Volume share,
• a close nearer the low increases the Sell Volume share.
The width of the strongest bin corresponds to Max Profile Width, and the remaining bins are scaled proportionally to it. The profile therefore shows both where volume concentrated and its approximate directional split.
By default, only the portion of a candle inside the zone is counted. Include Wick Volume Outside the Zone also adds volume from wicks extending beyond the range, assigning the excess to the nearest edge bin. This setting affects the profile, the Buy/Sell bars, the percentage label, and Volume Confirmation.
Buy/Sell Volume Split
Below the zone, two bars and a label can show the Buy/Sell Volume split for the entire range. The dominant side is:
• Buy — when Buy Volume is greater than or equal to Sell Volume,
• Sell — when Sell Volume is greater than Buy Volume.
Breakout
A zone ends when price closes outside its range:
• Breakout Up — Close > Zone Top + ATR margin,
• Breakout Down — Close < Zone Bottom − ATR margin.
If Volume Confirmation is disabled, the signal direction depends only on the breakout side. If enabled, a bullish breakout requires Buy Volume to be dominant, and a bearish breakout requires Sell Volume to be dominant.
The breakout candle is not added to the profile before this evaluation, so the breakout impulse itself cannot inflate the side that is confirming its own exit from the zone.
After a confirmed breakout, Recolor Zone on Breakout can change the box color to bullish or bearish. If the breakout is not confirmed, the zone stays neutral in color but is still closed.
TP/SL
After a confirmed signal, the TP/SL module plots Entry at the close of the breakout candle, a Stop Loss, and up to three targets. SL can be calculated as ATR × multiplier or as a fixed percentage from Entry. TP levels are derived from the chosen Risk:Reward ratios applied to the Entry-SL distance.
A new signal replaces the previous set of levels. The lines extend with price and stop once the market reaches the SL or the highest enabled TP. This is a level-planning tool, not an assessment of entry quality.
█ FEATURES
• Zone detection from a tested pivot high/pivot low pair, with a time-distance limit, close continuity check, and an optional ATR height limit.
• Volume Profile inside the zone, split into Price Bins with Buy and Sell Volume.
• Optional inclusion of wick volume extending outside the zone.
• Bars and label showing the total Buy/Sell Volume split below the zone.
• Upside and downside breakout signals, with optional Volume Confirmation.
• Zone recoloring on a confirmed breakout.
• Optional markers for pivot candles and numbered tests of their range.
• TP/SL module: Entry, SL, and TP1-TP3 based on ATR or percentage, and Risk:Reward.
• Alerts for upside and downside breakouts.
█ APPLICATIONS
Consolidation Analysis
The indicator locates ranges where price stays between a confirmed and tested pivot high and pivot low, producing a structure anchored to specific swing candles instead of a manually drawn box.
Zone Strength and Volume
The Volume Profile shows which price levels accumulated the most volume. The Buy/Sell split adds context on which side held the advantage across the whole range, not just at the moment of breakout.
Breakout Analysis
A signal marks price leaving the zone on a close outside its range. Volume Confirmation can narrow this down to breakouts that align with the volume split accumulated beforehand.
Example of Use
An active zone is better treated as an area of equilibrium than as a ready-made entry. Before acting on a signal, it helps to weigh:
• the breakout side,
• the dominant Buy/Sell Volume,
• the shape of the Volume Profile,
• the zone's position within the broader structure,
• momentum and context from a higher timeframe.
The zone being drawn, or a triangle appearing, is not on its own a sufficient reason to trade.
█ NOTES
• A test refers to the range of the pivot candle, not to a touch of the already-formed zone boundary.
• Volume Confirmation is optional. Without it, the signal depends only on the breakout direction.
• The breakout candle is excluded from the Volume Profile until after Volume Confirmation is evaluated.
• Buy and Sell Volume are derived from where the close sits within each candle's range. This is an estimate, not actual tape/order-flow buy/sell data.
• Show Breakout Signals is a shared switch: disabling it also disables the TP/SL module and the alerts, not just the on-chart triangles.
• TP/SL is a visual level-planning tool and does not assess the quality of a signal.
• This indicator does not replace independent market analysis or risk management.
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。