OPEN-SOURCE SCRIPT
Volume Structure

📊 Volume Structure is a market volume structure indicator that combines a horizontal volume profile, the level of maximum volume concentration, and automatically calculated volume-based support and resistance levels.
All components of the indicator are derived from the same volume distribution. This is not a simple combination of several independent tools: the volume profile serves as the underlying calculation model, while the Max Volume Level, support levels, and resistance levels are extracted directly from that model.
The indicator helps traders identify the price areas where the highest trading activity was concentrated during the selected period and locate additional significant volume zones relative to the current price.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎯 Purpose of the Indicator
A standard horizontal volume profile shows how trading volume is distributed across different price areas. However, when many price rows are displayed, interpreting the profile and identifying its most important concentrations may become difficult.
Volume Structure expands the traditional profile by automatically identifying:
• the price area containing the highest total calculated volume;
• up to two significant volume areas above the current price;
• up to two significant volume areas below the current price.
Together, these areas form a structural market map and help traders evaluate the position of the current price relative to important volume concentrations.
The indicator does not generate independent Buy or Sell signals and does not predict whether a specific level will hold or be broken.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙️ How the Volume Profile Is Calculated
The indicator first determines the highest and lowest prices reached during the selected calculation period.
The resulting price range is then divided into a user-defined number of horizontal price rows called Rows.
The volume of each candle is distributed among the price rows intersected by its body and wicks.
The calculation follows these steps:
The body volume of a bullish candle is assigned to the estimated up-volume component.
The body volume of a bearish candle is assigned to the estimated down-volume component.
The upper and lower candle wicks are calculated separately from the candle body.
The estimated wick volume is divided equally between the up-volume and down-volume components.
The volume of each candle component is distributed proportionally according to how much of the body or wick overlaps each horizontal price row.
The estimated up-volume and down-volume components are then added together to calculate the total volume of each price area.
🟢 The green section of the profile represents estimated up volume.
🔴 The red section of the profile represents estimated down volume.
It is important to understand that this is an OHLCV-based volume distribution model. It is not a true Bid/Ask profile, order-flow delta, or an exact separation of market buying and selling volume.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔴 Max Volume Level
The Max Volume Level represents the midpoint of the price row containing the highest total calculated volume during the selected period.
It is displayed as a solid red horizontal line.
This level identifies the price area with the greatest concentration of calculated volume within the current profile and can be used as a reference for the strongest area of price acceptance during the selected calculation window.
Because the line is plotted at the midpoint of a horizontal price row, it represents the central price of a volume area rather than the exact price of an individual transaction.
The Max Volume Level does not determine the direction of the next market movement by itself.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🧱 Volume Support and Volume Resistance
Using the same volume distribution, the indicator analyzes price rows located above and below the current closing price.
A potential volume node is initially considered significant when:
• its total volume is equal to or greater than the volume of the adjacent rows;
• its volume reaches the user-defined minimum proportion of the Max Volume Level volume;
• it is sufficiently separated from the Max Volume Level;
• it is sufficiently separated from another already selected structure level;
• its distance from the current price does not exceed the user-defined maximum.
A significant volume area above the current price is classified as Volume Resistance.
A significant volume area below the current price is classified as Volume Support.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔎 Level Selection Logic
The indicator first searches for the nearest qualifying local volume peak above and below the current price.
After the first level has been selected, the algorithm searches for a second level that:
• is located on the same side of the current price;
• is sufficiently separated from the first selected level;
• is sufficiently separated from the Max Volume Level;
• satisfies the configured distance and strength requirements.
When no qualifying local volume peak is available, the indicator applies a fallback procedure.
In this case, it selects the strongest eligible volume row on the corresponding side of the current price while preserving the distance and separation requirements.
Because of this fallback logic, a displayed support or resistance level is not always a strict local maximum of the volume distribution.
The indicator can display a maximum of:
• two Volume Resistance levels;
• two Volume Support levels.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💎 What Makes the Indicator Different
The volume profile, Max Volume Level, and structural levels are consecutive stages of one calculation process:
Candle volume is distributed across horizontal price rows.
The estimated up-volume and down-volume components form the horizontal profile.
The total volume of every price row is calculated.
The row with the highest total volume becomes the Max Volume Level.
Additional significant volume rows are evaluated as potential support and resistance levels.
The indicator therefore does more than display several volume-related components together.
It transforms the underlying volume distribution into a more readable structural market map while preserving the complete profile on the chart. Traders can see both the extracted levels and the volume model from which those levels were derived.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🧭 How to Interpret the Indicator
Horizontal Volume Profile
The longer a horizontal profile row is, the greater the amount of calculated volume assigned to that price area during the selected period.
The green and red sections should not be interpreted as an exact measurement of aggressive buyers and sellers.
Max Volume Level
The solid red line marks the midpoint of the price row containing the highest total calculated volume.
It serves as a reference for the strongest volume concentration within the current calculation window.
Volume Resistance
The red dashed lines represent selected volume concentrations above the current price.
When price approaches these areas, increased market activity may occur. However, the indicator does not guarantee that price will stop, reverse, or be rejected.
Volume Support
The green dashed lines represent selected volume concentrations below the current price.
They identify potentially significant price areas but do not guarantee a reversal or a successful support reaction.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📌 Practical Applications
The indicator can be used to:
• evaluate the position of the current price relative to significant volume concentrations;
• observe price behavior around the Max Volume Level;
• identify price areas that may require additional analysis;
• study price acceptance and rejection;
• analyze consolidation around high-volume areas;
• observe breakouts from significant volume zones;
• define areas of interest within an existing trading strategy;
• provide additional context for an already established trading scenario.
Volume-based levels should be used together with trend analysis, price structure, volatility assessment, trade confirmation rules, and risk management.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎛️ Indicator Settings
Bars for Calculation
Defines the number of recent candles included in the volume profile calculation.
A lower value makes the structure more responsive to recent market activity.
A higher value includes a longer historical period and generally produces a broader, slower-changing structure.
Default value: 120 bars.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Rows (Horizontal Bands)
Defines the number of horizontal price rows used to divide the calculation range.
A higher number of rows increases price resolution but may make the calculated levels more sensitive to small market changes.
A lower number of rows produces a smoother and more aggregated volume structure.
Default value: 24 rows.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Up Volume Color / Down Volume Color
Controls the colors of the estimated up-volume and down-volume sections of the profile.
These settings affect only the visual appearance and do not change the calculation.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Show Max Volume Level Label
Enables or disables the price label for the Max Volume Level.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Max Volume Level Color / Line Width
Controls the color and thickness of the Max Volume Level line.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Show Volume Support and Resistance
Enables or disables the automatically calculated volume support and resistance levels.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Volume Resistance Color / Volume Support Color
Controls the colors of the corresponding structure lines and labels.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Structure Line Width
Defines the thickness of the Volume Support and Volume Resistance lines.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Labels Offset to the Right
Controls the horizontal position of the level labels to the right of the current candle.
This setting changes only the visual placement of the labels and does not affect the calculation.
Default value: 25 bars.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Maximum Level Distance, %
Defines the maximum permitted percentage distance between the current closing price and a structural level.
If a volume area is located farther away than the selected percentage, it is not displayed as support or resistance.
Default value: 20%.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Minimum Volume Node Strength
Defines the minimum strength of a local volume node relative to the volume of the Max Volume Level.
For example, a value of 0.20 means that during the initial selection process, a qualifying local node must contain at least 20% of the volume of the Max Volume Level.
Default value: 0.20.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔄 Dynamic Recalculation
Volume Structure uses a rolling calculation window.
When a new candle appears, the oldest candle may leave the selected calculation period. At the same time, the highest and lowest prices, horizontal row boundaries, and volume distribution may change.
As a result, the following elements may change over time:
• the shape of the volume profile;
• the Max Volume Level;
• Volume Support levels;
• Volume Resistance levels.
The current unfinished candle is also included in the calculation. While that candle is forming, its volume and price range may change, causing the calculated levels to move, appear, or disappear.
The indicator displays the current structure derived from the latest calculation window. It does not preserve historical versions of previously calculated levels.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️ Limitations
• The up-volume and down-volume distribution is an OHLCV-based estimate, not actual Bid/Ask volume.
• The indicator does not have access to the exact amount of volume executed at every individual price inside a candle.
• Volume is distributed proportionally across the candle body and wicks.
• Every displayed level represents the midpoint of a horizontal price row rather than the exact price of an individual transaction.
• Results depend on the quality and completeness of the volume data available for the selected instrument.
• Increasing the number of horizontal rows improves visual resolution but also makes the profile more sensitive to changes in the calculation range.
• The levels are dynamic and may change while the current candle is forming.
• A fallback structure level may represent the strongest eligible volume area without being a strict local volume peak.
• A high-volume area may act as support, resistance, consolidation, price acceptance, or a breakout zone.
• The indicator cannot determine in advance which market scenario will occur.
• The script does not calculate entry points, stop-loss levels, profit targets, or trading performance statistics.
• The indicator does not guarantee profitable results.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🛡️ Important Information
Volume Structure is designed to provide analytical market context and is not a standalone trading system.
All trading decisions should be based on the user’s own analysis, trading plan, and risk management rules.
The indicator does not constitute financial or investment advice.
All components of the indicator are derived from the same volume distribution. This is not a simple combination of several independent tools: the volume profile serves as the underlying calculation model, while the Max Volume Level, support levels, and resistance levels are extracted directly from that model.
The indicator helps traders identify the price areas where the highest trading activity was concentrated during the selected period and locate additional significant volume zones relative to the current price.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎯 Purpose of the Indicator
A standard horizontal volume profile shows how trading volume is distributed across different price areas. However, when many price rows are displayed, interpreting the profile and identifying its most important concentrations may become difficult.
Volume Structure expands the traditional profile by automatically identifying:
• the price area containing the highest total calculated volume;
• up to two significant volume areas above the current price;
• up to two significant volume areas below the current price.
Together, these areas form a structural market map and help traders evaluate the position of the current price relative to important volume concentrations.
The indicator does not generate independent Buy or Sell signals and does not predict whether a specific level will hold or be broken.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚙️ How the Volume Profile Is Calculated
The indicator first determines the highest and lowest prices reached during the selected calculation period.
The resulting price range is then divided into a user-defined number of horizontal price rows called Rows.
The volume of each candle is distributed among the price rows intersected by its body and wicks.
The calculation follows these steps:
The body volume of a bullish candle is assigned to the estimated up-volume component.
The body volume of a bearish candle is assigned to the estimated down-volume component.
The upper and lower candle wicks are calculated separately from the candle body.
The estimated wick volume is divided equally between the up-volume and down-volume components.
The volume of each candle component is distributed proportionally according to how much of the body or wick overlaps each horizontal price row.
The estimated up-volume and down-volume components are then added together to calculate the total volume of each price area.
🟢 The green section of the profile represents estimated up volume.
🔴 The red section of the profile represents estimated down volume.
It is important to understand that this is an OHLCV-based volume distribution model. It is not a true Bid/Ask profile, order-flow delta, or an exact separation of market buying and selling volume.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔴 Max Volume Level
The Max Volume Level represents the midpoint of the price row containing the highest total calculated volume during the selected period.
It is displayed as a solid red horizontal line.
This level identifies the price area with the greatest concentration of calculated volume within the current profile and can be used as a reference for the strongest area of price acceptance during the selected calculation window.
Because the line is plotted at the midpoint of a horizontal price row, it represents the central price of a volume area rather than the exact price of an individual transaction.
The Max Volume Level does not determine the direction of the next market movement by itself.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🧱 Volume Support and Volume Resistance
Using the same volume distribution, the indicator analyzes price rows located above and below the current closing price.
A potential volume node is initially considered significant when:
• its total volume is equal to or greater than the volume of the adjacent rows;
• its volume reaches the user-defined minimum proportion of the Max Volume Level volume;
• it is sufficiently separated from the Max Volume Level;
• it is sufficiently separated from another already selected structure level;
• its distance from the current price does not exceed the user-defined maximum.
A significant volume area above the current price is classified as Volume Resistance.
A significant volume area below the current price is classified as Volume Support.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔎 Level Selection Logic
The indicator first searches for the nearest qualifying local volume peak above and below the current price.
After the first level has been selected, the algorithm searches for a second level that:
• is located on the same side of the current price;
• is sufficiently separated from the first selected level;
• is sufficiently separated from the Max Volume Level;
• satisfies the configured distance and strength requirements.
When no qualifying local volume peak is available, the indicator applies a fallback procedure.
In this case, it selects the strongest eligible volume row on the corresponding side of the current price while preserving the distance and separation requirements.
Because of this fallback logic, a displayed support or resistance level is not always a strict local maximum of the volume distribution.
The indicator can display a maximum of:
• two Volume Resistance levels;
• two Volume Support levels.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
💎 What Makes the Indicator Different
The volume profile, Max Volume Level, and structural levels are consecutive stages of one calculation process:
Candle volume is distributed across horizontal price rows.
The estimated up-volume and down-volume components form the horizontal profile.
The total volume of every price row is calculated.
The row with the highest total volume becomes the Max Volume Level.
Additional significant volume rows are evaluated as potential support and resistance levels.
The indicator therefore does more than display several volume-related components together.
It transforms the underlying volume distribution into a more readable structural market map while preserving the complete profile on the chart. Traders can see both the extracted levels and the volume model from which those levels were derived.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🧭 How to Interpret the Indicator
Horizontal Volume Profile
The longer a horizontal profile row is, the greater the amount of calculated volume assigned to that price area during the selected period.
The green and red sections should not be interpreted as an exact measurement of aggressive buyers and sellers.
Max Volume Level
The solid red line marks the midpoint of the price row containing the highest total calculated volume.
It serves as a reference for the strongest volume concentration within the current calculation window.
Volume Resistance
The red dashed lines represent selected volume concentrations above the current price.
When price approaches these areas, increased market activity may occur. However, the indicator does not guarantee that price will stop, reverse, or be rejected.
Volume Support
The green dashed lines represent selected volume concentrations below the current price.
They identify potentially significant price areas but do not guarantee a reversal or a successful support reaction.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📌 Practical Applications
The indicator can be used to:
• evaluate the position of the current price relative to significant volume concentrations;
• observe price behavior around the Max Volume Level;
• identify price areas that may require additional analysis;
• study price acceptance and rejection;
• analyze consolidation around high-volume areas;
• observe breakouts from significant volume zones;
• define areas of interest within an existing trading strategy;
• provide additional context for an already established trading scenario.
Volume-based levels should be used together with trend analysis, price structure, volatility assessment, trade confirmation rules, and risk management.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎛️ Indicator Settings
Bars for Calculation
Defines the number of recent candles included in the volume profile calculation.
A lower value makes the structure more responsive to recent market activity.
A higher value includes a longer historical period and generally produces a broader, slower-changing structure.
Default value: 120 bars.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Rows (Horizontal Bands)
Defines the number of horizontal price rows used to divide the calculation range.
A higher number of rows increases price resolution but may make the calculated levels more sensitive to small market changes.
A lower number of rows produces a smoother and more aggregated volume structure.
Default value: 24 rows.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Up Volume Color / Down Volume Color
Controls the colors of the estimated up-volume and down-volume sections of the profile.
These settings affect only the visual appearance and do not change the calculation.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Show Max Volume Level Label
Enables or disables the price label for the Max Volume Level.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Max Volume Level Color / Line Width
Controls the color and thickness of the Max Volume Level line.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Show Volume Support and Resistance
Enables or disables the automatically calculated volume support and resistance levels.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Volume Resistance Color / Volume Support Color
Controls the colors of the corresponding structure lines and labels.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Structure Line Width
Defines the thickness of the Volume Support and Volume Resistance lines.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Labels Offset to the Right
Controls the horizontal position of the level labels to the right of the current candle.
This setting changes only the visual placement of the labels and does not affect the calculation.
Default value: 25 bars.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Maximum Level Distance, %
Defines the maximum permitted percentage distance between the current closing price and a structural level.
If a volume area is located farther away than the selected percentage, it is not displayed as support or resistance.
Default value: 20%.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Minimum Volume Node Strength
Defines the minimum strength of a local volume node relative to the volume of the Max Volume Level.
For example, a value of 0.20 means that during the initial selection process, a qualifying local node must contain at least 20% of the volume of the Max Volume Level.
Default value: 0.20.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔄 Dynamic Recalculation
Volume Structure uses a rolling calculation window.
When a new candle appears, the oldest candle may leave the selected calculation period. At the same time, the highest and lowest prices, horizontal row boundaries, and volume distribution may change.
As a result, the following elements may change over time:
• the shape of the volume profile;
• the Max Volume Level;
• Volume Support levels;
• Volume Resistance levels.
The current unfinished candle is also included in the calculation. While that candle is forming, its volume and price range may change, causing the calculated levels to move, appear, or disappear.
The indicator displays the current structure derived from the latest calculation window. It does not preserve historical versions of previously calculated levels.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠️ Limitations
• The up-volume and down-volume distribution is an OHLCV-based estimate, not actual Bid/Ask volume.
• The indicator does not have access to the exact amount of volume executed at every individual price inside a candle.
• Volume is distributed proportionally across the candle body and wicks.
• Every displayed level represents the midpoint of a horizontal price row rather than the exact price of an individual transaction.
• Results depend on the quality and completeness of the volume data available for the selected instrument.
• Increasing the number of horizontal rows improves visual resolution but also makes the profile more sensitive to changes in the calculation range.
• The levels are dynamic and may change while the current candle is forming.
• A fallback structure level may represent the strongest eligible volume area without being a strict local volume peak.
• A high-volume area may act as support, resistance, consolidation, price acceptance, or a breakout zone.
• The indicator cannot determine in advance which market scenario will occur.
• The script does not calculate entry points, stop-loss levels, profit targets, or trading performance statistics.
• The indicator does not guarantee profitable results.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🛡️ Important Information
Volume Structure is designed to provide analytical market context and is not a standalone trading system.
All trading decisions should be based on the user’s own analysis, trading plan, and risk management rules.
The indicator does not constitute financial or investment advice.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Trading tools by MarketStructureLab. Professional indicators, algorithms & market structure logic. Get access: marketstructurelab.com
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Trading tools by MarketStructureLab. Professional indicators, algorithms & market structure logic. Get access: marketstructurelab.com
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.