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.
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:
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:
//@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.
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.
HVNs act as strong areas of agreement and potential support/resistance, while LVNs represent areas of rapid transit and weak support/resistance.
//@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)
The Value Area represents where the majority of trades occurred and where market participants found "fair value."
//@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)
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.
//@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)
To get the most from Volume Profile in Pine Script:
Volume Profile helps visualize where 'smart money' (large institutions) has likely accumulated or distributed positions, as these are often the areas of highest volume.
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.
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