Logo
OFFLINEPIXEL
/ pinescript-strategies / pine-script-volumeprofile

$ Pine Script Volume Profile

Master this powerful technical analysis tool in TradingView's Pine Script that displays trading activity over a specified price range, revealing key areas of supply and demand for more informed trading decisions.

500+ Clients Helped
100% Satisfaction
Live Trading Ready
⚠️
Trading financial markets carries risk. All content (PineScript code, indicators, strategies) on this website is for educational purposes only. Past performance is not indicative of future results. By using any code or information from this site, you agree that you are solely responsible for your trading decisions. The author disclaims all liability for any losses incurred. To gain from experts experiences, You can always try our Invite Only Scripts
01

What is Volume Profile?

Volume Profile is an advanced charting indicator that displays trading activity over a specified price range during a specified period. It shows the total volume traded at each price level, often represented as a horizontal histogram on the left or right side of the price chart. Unlike traditional volume indicators that show total volume traded over a specific time period (e.g., a bar), Volume Profile reveals *where* that volume was traded across different price points.

This insight into the distribution of volume provides a deeper understanding of market dynamics and participant behavior. Key components derived from the Volume Profile include:

  • Point of Control (POC): The price level with the highest traded volume for the specified period. It represents the price where the most trading activity occurred and is considered a fair value area.
  • Value Area (VA): The price range where a significant percentage of the total volume (typically 70% or 68%) was traded. It signifies where the majority of participants found value.
  • High Volume Nodes (HVN): Price levels where a large amount of volume was traded, indicating areas of agreement or consolidation. These often act as strong support or resistance.
  • Low Volume Nodes (LVN): Price levels where very little volume was traded, indicating areas of disagreement or rapid price movement. These often act as weak support/resistance and tend to be easily broken through.
02

Components and Calculation (Conceptual)

The Volume Profile is constructed by taking all the trades (volume) that occurred within a defined time window (e.g., a day, a week, or a fixed number of bars) and categorizing them into discrete price "bins" or levels. For each bin, the total volume traded at that price level is accumulated. This accumulation is then displayed as a horizontal bar, with longer bars indicating more volume traded at that price.

The calculation conceptually involves:

  1. Define the Analysis Period: This can be a specific session (e.g., daily, weekly) or a fixed number of bars (e.g., last 100 bars).
  2. Determine Price Range: Identify the high and low prices within the analysis period.
  3. Define Bins: Divide the price range into a specified number of equal price "bins." For example, if the range is $10 and you want 10 bins, each bin would be $1 wide.
  4. Distribute Volume: For each bar within the analysis period, distribute its volume across the price bins that its `high`-`low` range covers. If a bar's `high` is in one bin and its `low` in another, its volume is proportionally distributed.
  5. Aggregate Volume per Bin: Sum up the volume for each price bin.
  6. Identify POC, VA, HVN, LVN: Once the volume distribution is complete, the POC is the bin with the highest volume. The Value Area is found by accumulating volume from the POC outwards until the specified percentage (e.g., 70%) of total volume is reached.
03

Basic Volume Profile Implementation in Pine Script

pine-script@terminal
//@version=5
indicator("My Volume Profile", overlay=true, max_bars_back=500)

// --- User Inputs ---
profileType = input.string("Fixed Range", title="Profile Type", options=["Fixed Range", "Session Profile"])
fixedRangeBars = input.int(100, title="Fixed Range Bars (for Fixed Range Profile)", minval=10, maxval=500)
numberOfRows = input.int(20, title="Number of Rows (Bins)", minval=5, maxval=100)
valueAreaPercentage = input.int(70, title="Value Area (%)", minval=50, maxval=99)

// --- Plotting Colors ---
upVolumeColor = input.color(color.new(color.lime, 40), title="Up Volume Color")
downVolumeColor = input.color(color.new(color.red, 40), title="Down Volume Color")
pocColor = input.color(color.new(color.purple, 0), title="POC Color")
vaColor = input.color(color.new(color.yellow, 60), title="Value Area Color")

// --- Implement Volume Profile Logic ---
if profileType == "Fixed Range"
    profile = volume.profile_fixed(fixedRangeBars, numberOfRows, valueAreaPercentage)
    if barstate.islast and not na(profile)
        profile.plot(upVolumeColor, downVolumeColor, pocColor, vaColor)
else if profileType == "Session Profile"
    profile = volume.profile_session(numberOfRows, valueAreaPercentage)
    if not na(profile)
        profile.plot(upVolumeColor, downVolumeColor, pocColor, vaColor)

// Note: Pine Script's built-in `volume` module handles the complex drawing
// of the histogram, POC line, and Value Area shading automatically.
$ ✓ Compiled successfully
04

Supply & Demand Hotspots

Supply & Demand Hotspots

Volume Profile helps identify where the majority of trading activity occurred, pinpointing true supply and demand zones where institutions and large players have likely taken positions.

05

Practical Volume Profile Trading Strategies

1. Support and Resistance with HVNs & LVNs

HVNs act as strong areas of agreement and potential support/resistance, while LVNs represent areas of rapid transit and weak support/resistance.

  • HVN as Support/Resistance: When price approaches an HVN, it's likely to consolidate or reverse as significant past trading activity suggests strong conviction at that level.
  • LVN as Price Magnet/Breakout: Price tends to move quickly through LVNs because there was little prior agreement.
//@version=5
strategy("VP: HVN/LVN Strategy", overlay=true)

numberOfRows = input.int(30, title="Number of Rows (Bins)", minval=5, maxval=100)
valueAreaPercentage = input.int(70, title="Value Area (%)", minval=50, maxval=99)

profile = volume.profile_session(numberOfRows, valueAreaPercentage)

if not na(profile)
    profile.plot(
        color.new(color.lime, 40),
        color.new(color.red, 40),
        color.new(color.purple, 0),
        color.new(color.yellow, 60)
    )

if not na(profile) and barstate.isconfirmed
    pocPrice = profile.poc_price
    longCondition = ta.crossover(close, pocPrice)
    shortCondition = ta.crossunder(close, pocPrice)
    if longCondition
        strategy.entry("Long POC Break", strategy.long)
    if shortCondition
        strategy.entry("Short POC Break", strategy.short)
    strategy.close("Long POC Break", when=shortCondition)
    strategy.close("Short POC Break", when=longCondition)

2. Value Area (VA) as Fair Price Zone

The Value Area represents where the majority of trades occurred and where market participants found "fair value."

  • Trading within Value Area: Price tends to spend a significant amount of time within the Value Area.
  • Opening outside Value Area: If price opens significantly outside the previous day's Value Area, it often suggests a trending day.
  • VA as Support/Resistance: The Value Area High (VAH) and Value Area Low (VAL) act as dynamic support and resistance levels.
//@version=5
strategy("VP: Value Area Strategy", overlay=true)

numberOfRows = input.int(30, title="Number of Rows (Bins)", minval=5, maxval=100)
valueAreaPercentage = input.int(70, title="Value Area (%)", minval=50, maxval=99)

profile = volume.profile_session(numberOfRows, valueAreaPercentage)

if not na(profile)
    profile.plot(
        color.new(color.lime, 40),
        color.new(color.red, 40),
        color.new(color.purple, 0),
        color.new(color.yellow, 60)
    )

var float prevVAH = na
var float prevVAL = na
isNewSession = ta.change(time("D"))

if isNewSession[1] and not na(profile[1])
    prevVAH := profile[1].value_area_high
    prevVAL := profile[1].value_area_low

prevVAH := nz(prevVAH[1], prevVAH)
prevVAL := nz(prevVAL[1], prevVAL)

if not na(prevVAH) and not na(prevVAL)
    longAbsorption = open < prevVAL and close > prevVAL
    shortAbsorption = open > prevVAH and close < prevVAH
    if (longAbsorption)
        strategy.entry("Long VA Absorb", strategy.long)
    if (shortAbsorption)
        strategy.entry("Short VA Absorb", strategy.short)

3. POC Rejection/Breakout

The Point of Control (POC) is the single most traded price level. It acts as a significant magnet and a strong area of support/resistance.

  • POC Rejection: Price rallies towards the POC and then reverses, suggesting strong supply at POC.
  • POC Breakout: Price decisively breaks and holds above/below the POC, often indicating a shift in fair value.
//@version=5
strategy("VP: POC Strategy", overlay=true)

numberOfRows = input.int(30, title="Number of Rows (Bins)", minval=5, maxval=100)
valueAreaPercentage = input.int(70, title="Value Area (%)", minval=50, maxval=99)

profile = volume.profile_session(numberOfRows, valueAreaPercentage)

if not na(profile)
    profile.plot(
        color.new(color.lime, 40),
        color.new(color.red, 40),
        color.new(color.purple, 0),
        color.new(color.yellow, 60)
    )

var float prevPOC = na
isNewSession = ta.change(time("D"))

if isNewSession[1] and not na(profile[1])
    prevPOC := profile[1].poc_price

prevPOC := nz(prevPOC[1], prevPOC)

if not na(prevPOC)
    longPOCBreakout = close > prevPOC and close[1] <= prevPOC[1] and volume > ta.sma(volume, 20) * 1.2
    shortPOCBreakout = close < prevPOC and close[1] >= prevPOC[1] and volume > ta.sma(volume, 20) * 1.2
    if (longPOCBreakout)
        strategy.entry("Long POC Breakout", strategy.long)
    if (shortPOCBreakout)
        strategy.entry("Short POC Breakout", strategy.short)
06

Optimizing Volume Profile Performance

To get the most from Volume Profile in Pine Script:

  • Contextual Analysis: Volume Profile is best used in conjunction with price action and overall market context.
  • Timeframe Selection: The chosen `profileType` and the chart's timeframe greatly impact the profile's relevance.
  • Number of Rows (Bins): Experiment with the `numberOfRows`. Start with 20-30 and adjust.
  • Value Area Percentage: The default 70% is common, but some traders prefer 68%.
  • Confluence with Other Indicators: Volume Profile levels gain significant strength when they align with Moving Averages, Fibonacci Retracements, Trendlines, and Psychological price levels.
  • Volume Confirmation: Always seek confirmation from volume. A breakout with strong, increasing volume is more reliable.
  • Market Open/Close Behavior: Pay attention to how price reacts to the previous session's POC and Value Area boundaries.
  • Fixed vs. Session Profile: Understand when to use each. `volume.profile_session` is for recurring periods while `volume.profile_fixed` is for analyzing specific ranges.
07

Institutional Footprint

Institutional Footprint

Volume Profile helps visualize where 'smart money' (large institutions) has likely accumulated or distributed positions, as these are often the areas of highest volume.

08

Common Volume Profile Pitfalls

  • Lagging Nature: Volume Profile shows where volume *has been* traded, not where it *will* be traded.
  • False Signals: Price can temporarily penetrate or "fake out" around key Volume Profile levels.
  • Over-Reliance: Using Volume Profile as the sole decision-making tool without considering broader market context.
  • Data Quality: The accuracy depends on the quality and granularity of volume data.
  • Visual Clutter: With too many profiles or too many rows, the chart can become overly cluttered.
  • Dynamic Nature in Strategies: Implementing strategies based on *previous* session's data can be tricky.
09

Conclusion

Conclusion

Volume Profile is an exceptionally powerful and insightful technical analysis tool available in Pine Script for TradingView. By providing a clear visualization of trading activity across different price levels, it allows traders to identify key areas of supply and demand, understand market conviction, and pinpoint significant support and resistance zones. Mastering its components – the Point of Control (POC), Value Area (VA), High Volume Nodes (HVN), and Low Volume Nodes (LVN) – can significantly enhance your pine script strategies. While requiring careful consideration of its settings and integration with other technical analysis, Volume Profile provides a unique "x-ray" view into market structure, helping you make more informed and robust trading decisions by understanding where the true battle between buyers and sellers took place.

Enhance Your Trading

Get a high-performance Pine Script analysis tool for actionable market insights, designed for traders on the move.

This strategy runs in live mode on TradingView, helping you identify potential opportunities.

Get Pine Script Strategy