//@version=6 indicator("Workshop 12 Session VWAP", overlay=true) session = input.session("0930-1600", "Day session") zone = input.string("America/New_York", "Time zone") if not timeframe.isintraday runtime.error("Use an intraday time chart") inside = not na(time(timeframe.period, session, zone)) dayKey = time("1D", "0000-0000", zone) newDay = ta.change(dayKey) != 0 restart = inside and (not inside[1] or newDay) var float pv = 0.0 var float total = 0.0 var bool bad = false if restart pv := 0.0 total := 0.0 bad := false if inside bad := bad or na(volume) if not na(volume) and volume > 0 pv += hlc3 * volume total += volume value = (inside and not bad and total > 0 ? pv / total : na) plot(value, "Session estimate", color=color.blue, style=plot.style_linebr)