Code Library / Volume Analysis
Pine Script Volume Profile
Volume distribution by price level.
Language: Pine Script · Category: Volume Analysis · Tags: volume profile, Pine Script, POC, value area, TradingView
Source code
//@version=5
indicator("Vol Profile",overlay=true)
lb=input.int(100,"Lookback"); lvls=input.int(20,"Levels")
hi=ta.highest(high,lb); lo=ta.lowest(low,lb)
step=(hi-lo)/lvls
var float[] vl=array.new_float(lvls,0)
if barstate.islast
array.fill(vl,0)
for i=0 to lb-1
l=math.floor((close[i]-lo)/step)
l:=math.min(math.max(l,0),lvls-1)
array.set(vl,int(l),array.get(vl,int(l))+volume[i])How to use this snippet
This is a building block, not a finished trading system. Paste it into your own Pine Script project, compile it, and test it on a demo account with your broker's real spreads before relying on it. You can convert it to MQL4 or MQL5 with the Pine Script converter.