Custom volume profile
A custom volume profile: fold the footprint ladder of the New York cash session into one profile, drawn the way every other profile on the chart is drawn, with the value area and the point of control marked on price.
//@xfscript 1
indicator("Custom Volume Profile")
let window: string = "0930-1600"
let value_percent: float = input.float(70, "valuePercent", "Value area percent", 10, 100, 5)
let max_bars: int = input.int(2000, "maxBars", "Longest session", 10, 5000, 10)
let poc_color: color = input.color("#F59E0B", "pocColor", "Point of control")
let value_color: color = input.color("#6B7280", "valueColor", "Value area")
let in_session: bool = session.in(window, "America/New_York")
let was_in: bool = bar_index > 0 && in_session[1]
let first_bar: bool = in_session && !was_in
let session_end: bool = was_in && !in_session
var elapsed: float = 0
elapsed := nz(elapsed[1], 0)
if first_bar {
elapsed := 1
}
if in_session && !first_bar {
elapsed := elapsed + 1
}
let folded: int = math.round(math.clamp(elapsed, 1, max_bars))
profile.fold(session_end, folded, value_percent)
let poc: float = cell.poc_price()
let value_high: float = cell.va_high(value_percent)
let value_low: float = cell.va_low(value_percent)
let has_ladder: bool = cell.available()
if in_session && has_ladder {
plot.dot(true, poc, poc_color, 3)
plot.band(value_high, value_low, value_color, value_color)
}
plot.hline(poc, poc_color, 1, "dotted", "POC")