VWAP 3x Session Reset
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © EternallyCurious

//@version=5
indicator(title="VWAP 3x Session Reset", shorttitle="VWAP 3xReset", overlay=true)

session1 = input.session("1700-0200", "Session 1")
session2 = input.session("0200-0830", "Session 2")
session3 = input.session("0830-1600", "Session 3")
timeZone = input.string("America/Chicago", "Time Zone")
stdevMultiplierInput = 2

// Detects the beginning of a session
sessionBegins(sess) =>
    t = time("", sess, timeZone)
    timeframe.isintraday and (not barstate.isfirst) and na(t[1]) and not na(t)

sessionIsActive(session) => 
    not na(time("", session, timeZone)) ? true : false

sessionStart = sessionBegins(session1) or sessionBegins(session2) or sessionBegins(session3)

plotValue = not sessionStart and (sessionIsActive(session1) or sessionIsActive(session2) or sessionIsActive(session3))

[vwap, upper, lower] = ta.vwap(open, sessionStart, stdevMultiplierInput)
plot(vwap, color = plotValue? color.yellow : color.rgb(0, 0, 0, 100), display=display.all-display.price_scale)
plot(upper, color = plotValue? color.green : color.rgb(0, 0, 0, 100), display=display.all-display.price_scale)
plot(lower, color = plotValue? color.green : color.rgb(0, 0, 0, 100), display=display.all-display.price_scale)