RTH & ETH VWAPs [vnhilton]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © vnhilton

//@version=5
indicator("RTH & ETH VWAPs [vnhilton]", "RTH&ETH VWAPS", true)

//RTH Timezone
rth = time(timeframe.period, session.regular, syminfo.timezone)

//Parameters
ethRTHToggle = input.bool(false, "Hide ETH VWAP Lines During RTH Session?", "Recommended to turn on if using closest VWAP Bands")
vwapSize         = input.int(2, "VWAP Circle Size", 1)

srcrth = input(hlc3, "Source For RTH VWAP", group="RTH Parameters")

stddevRTHM1 = input.float(1, "STDDEV Bands Multiplier #1", 0, group="RTH Parameters")
stddevRTHM2 = input.float(2, "STDDEV Bands Multiplier #2", 0, group="RTH Parameters")
stddevRTHM3 = input.float(3, "STDDEV Bands Multiplier #3", 0, group="RTH Parameters")

srceth = input(hlc3, "Source For ETH VWAP", group="ETH Parameters")
stddevETHM1 = input.float(1, "STDDEV Bands Multiplier #1", 0, group="ETH Parameters")
stddevETHM2 = input.float(2, "STDDEV Bands Multiplier #2", 0, group="ETH Parameters")
stddevETHM3 = input.float(3, "STDDEV Bands Multiplier #3", 0, group="ETH Parameters")

//Base VWAPs
[vwapR1, upperR1, lowerR1] = ta.vwap(srcrth, timeframe.change("D"), stddevRTHM1)
[vwapE1, upperE1, lowerE1] = ta.vwap(srceth, timeframe.change("D"), stddevRTHM1)

[vwapR2, upperR2, lowerR2] = ta.vwap(srcrth, timeframe.change("D"), stddevRTHM2)
[vwapE2, upperE2, lowerE2] = ta.vwap(srceth, timeframe.change("D"), stddevRTHM2)

[vwapR3, upperR3, lowerR3] = ta.vwap(srcrth, timeframe.change("D"), stddevRTHM3)
[vwapE3, upperE3, lowerE3] = ta.vwap(srceth, timeframe.change("D"), stddevRTHM3)

//RTH & ETH VWAPs
[rthVWAP1, rthVWAPUpper1, rthVWAPLower1] = request.security(ticker.modify(syminfo.tickerid, session.regular), timeframe.period, [vwapR1, upperR1, lowerR1])
[ethVWAP1, ethVWAPUpper1, ethVWAPLower1] = request.security(ticker.modify(syminfo.tickerid, session.extended), timeframe.period, [vwapE1, upperE1, lowerE1])

[rthVWAP2, rthVWAPUpper2, rthVWAPLower2] = request.security(ticker.modify(syminfo.tickerid, session.regular), timeframe.period, [vwapR2, upperR2, lowerR2])
[ethVWAP2, ethVWAPUpper2, ethVWAPLower2] = request.security(ticker.modify(syminfo.tickerid, session.extended), timeframe.period, [vwapE2, upperE2, lowerE2])

[rthVWAP3, rthVWAPUpper3, rthVWAPLower3] = request.security(ticker.modify(syminfo.tickerid, session.regular), timeframe.period, [vwapR3, upperR3, lowerR3])
[ethVWAP3, ethVWAPUpper3, ethVWAPLower3] = request.security(ticker.modify(syminfo.tickerid, session.extended), timeframe.period, [vwapE3, upperE3, lowerE3])

//Plots
rthPlot = plot(rth ? rthVWAP1 : na, "RTH VWAP", color.rgb(255, 244, 1, 0), style=plot.style_linebr)
plot(rthVWAP1 <= high and rthVWAP1 >= low and rth ? rthVWAP1 : na, "RTH VWAP Circles", color.rgb(255, 244, 1, 0), vwapSize, style=plot.style_circles)

upperRPlot1 = plot(rth ? rthVWAPUpper1 : na, "Upper RTH VWAP Band #1", color.rgb(255, 244, 1, 50), style=plot.style_linebr)
lowerRPlot1 = plot(rth ? rthVWAPLower1 : na, "Lower RTH VWAP Band #1", color.rgb(255, 244, 1, 50), style=plot.style_linebr)
upperRPlot2 = plot(rth ? rthVWAPUpper2 : na, "Upper RTH VWAP Band #2", color.rgb(255, 244, 1, 55), style=plot.style_linebr)
lowerRPlot2 = plot(rth ? rthVWAPLower2 : na, "Lower RTH VWAP Band #2", color.rgb(255, 244, 1, 55), style=plot.style_linebr)
upperRPlot3 = plot(rth ? rthVWAPUpper3 : na, "Upper RTH VWAP Band #3", color.rgb(255, 244, 1, 60), style=plot.style_linebr)
lowerRPlot3 = plot(rth ? rthVWAPLower3 : na, "Lower RTH VWAP Band #3", color.rgb(255, 244, 1, 60), style=plot.style_linebr)

ethPlot = plot(ethRTHToggle ? rth ? na : ethVWAP1 : ethVWAP1, "ETH VWAP", color.rgb(255, 255, 255, 0), style=plot.style_linebr)
plot(ethVWAP1 <= high and ethVWAP1 >= low ? ethVWAP1 : na, "ETH VWAP Circles", color.rgb(255, 255, 255, 0), vwapSize, style=plot.style_circles)

upperEPlot1 = plot(ethRTHToggle ? rth ? na : ethVWAPUpper1 : ethVWAPUpper1, "Upper ETH VWAP Band #1", color.rgb(255, 255, 255, 50), style=plot.style_linebr)
lowerEPlot1 = plot(ethRTHToggle ? rth ? na : ethVWAPLower1 : ethVWAPLower1, "Lower ETH VWAP Band #1", color.rgb(255, 255, 255, 50), style=plot.style_linebr)
upperEPlot2 = plot(ethRTHToggle ? rth ? na : ethVWAPUpper2 : ethVWAPUpper2, "Upper ETH VWAP Band #2", color.rgb(255, 255, 255, 55), style=plot.style_linebr)
lowerEPlot2 = plot(ethRTHToggle ? rth ? na : ethVWAPLower2 : ethVWAPLower2, "Lower ETH VWAP Band #2", color.rgb(255, 255, 255, 55), style=plot.style_linebr)
upperEPlot3 = plot(ethRTHToggle ? rth ? na : ethVWAPUpper3 : ethVWAPUpper3, "Upper ETH VWAP Band #3", color.rgb(255, 255, 255, 60), style=plot.style_linebr)
lowerEPlot3 = plot(ethRTHToggle ? rth ? na : ethVWAPLower3 : ethVWAPLower3, "Lower ETH VWAP Band #3", color.rgb(255, 255, 255, 60), style=plot.style_linebr)

closestUPlot1 = plot(rth ? rthVWAPUpper1 < ethVWAPUpper1 ? rthVWAPUpper1 : ethVWAPUpper1 : na, "Closest VWAP Upper Band #1", color.rgb(255, 255, 255, 50), style=plot.style_linebr, display=display.none)
closestDPlot1 = plot(rth ? rthVWAPLower1 >= ethVWAPLower1 ? rthVWAPLower1 : ethVWAPLower1 : na, "Closest VWAP Lower Band #1", color.rgb(255, 255, 255, 50), style=plot.style_linebr, display=display.none)
closestUPlot2 = plot(rth ? rthVWAPUpper2 < ethVWAPUpper2 ? rthVWAPUpper2 : ethVWAPUpper2 : na, "Closest VWAP Upper Band #2", color.rgb(255, 255, 255, 55), style=plot.style_linebr, display=display.none)
closestDPlot2 = plot(rth ? rthVWAPLower2 >= ethVWAPLower2 ? rthVWAPLower2 : ethVWAPLower2 : na, "Closest VWAP Lower Band #2", color.rgb(255, 255, 255, 55), style=plot.style_linebr, display=display.none)
closestUPlot3 = plot(rth ? rthVWAPUpper3 < ethVWAPUpper3 ? rthVWAPUpper3 : ethVWAPUpper3 : na, "Closest VWAP Upper Band #3", color.rgb(255, 255, 255, 60), style=plot.style_linebr, display=display.none)
closestDPlot3 = plot(rth ? rthVWAPLower3 >= ethVWAPLower3 ? rthVWAPLower3 : ethVWAPLower3 : na, "Closest VWAP Lower Band #3", color.rgb(255, 255, 255, 60), style=plot.style_linebr, display=display.none)

fill(plot1=rthPlot, plot2=ethPlot, top_value=rthVWAP1 >= ethVWAP1 ? rthVWAP1 : ethVWAP1, bottom_value=rthVWAP1 >= ethVWAP1 ? ethVWAP1 : rthVWAP1, top_color=rthVWAP1 >= ethVWAP1 ? color.rgb(255, 244, 1, 90) : color.rgb(255, 255, 255, 100), bottom_color=rthVWAP1 >= ethVWAP1 ? color.rgb(255, 255, 255, 100) : color.rgb(255, 244, 1, 90), title="RTH & ETH VWAPs Plot Fill")

fill(plot1=upperRPlot1, plot2=upperEPlot1, top_value=rthVWAPUpper1 >= ethVWAPUpper1 ? rthVWAPUpper1 : ethVWAPUpper1, bottom_value=rthVWAPUpper1 >= ethVWAPUpper1 ? ethVWAPUpper1 : rthVWAPUpper1, top_color=rthVWAPUpper1 >= ethVWAPUpper1 ? color.rgb(255, 244, 1, 90) : color.rgb(255, 255, 255, 100), bottom_color=rthVWAPUpper1 >= ethVWAPUpper1 ? color.rgb(255, 255, 255, 100) : color.rgb(255, 244, 1, 90), title="RTH & ETH VWAPs Upper Band #1 Plot Fill")
fill(plot1=upperRPlot2, plot2=upperEPlot2, top_value=rthVWAPUpper2 >= ethVWAPUpper2 ? rthVWAPUpper2 : ethVWAPUpper2, bottom_value=rthVWAPUpper2 >= ethVWAPUpper2 ? ethVWAPUpper2 : rthVWAPUpper2, top_color=rthVWAPUpper2 >= ethVWAPUpper2 ? color.rgb(255, 244, 1, 90) : color.rgb(255, 255, 255, 100), bottom_color=rthVWAPUpper2 >= ethVWAPUpper2 ? color.rgb(255, 255, 255, 100) : color.rgb(255, 244, 1, 90), title="RTH & ETH VWAPs Upper Band #2 Plot Fill")
fill(plot1=upperRPlot3, plot2=upperEPlot3, top_value=rthVWAPUpper3 >= ethVWAPUpper3 ? rthVWAPUpper3 : ethVWAPUpper3, bottom_value=rthVWAPUpper3 >= ethVWAPUpper3 ? ethVWAPUpper3 : rthVWAPUpper3, top_color=rthVWAPUpper3 >= ethVWAPUpper3 ? color.rgb(255, 244, 1, 90) : color.rgb(255, 255, 255, 100), bottom_color=rthVWAPUpper3 >= ethVWAPUpper3 ? color.rgb(255, 255, 255, 100) : color.rgb(255, 244, 1, 90), title="RTH & ETH VWAPs Upper Band #3 Plot Fill")

fill(plot1=lowerRPlot1, plot2=lowerEPlot1, top_value=rthVWAPLower1 >= ethVWAPLower1 ? rthVWAPLower1 : ethVWAPLower1, bottom_value=rthVWAPLower1 >= ethVWAPLower1 ? ethVWAPLower1 : rthVWAPLower1, top_color=rthVWAPLower1 >= ethVWAPLower1 ? color.rgb(255, 244, 1, 90) : color.rgb(255, 255, 255, 100), bottom_color=rthVWAPLower1 >= ethVWAPLower1 ? color.rgb(255, 255, 255, 100) : color.rgb(255, 244, 1, 90), title="RTH & ETH VWAPs Lower Band #1 Plot Fill")
fill(plot1=lowerRPlot2, plot2=lowerEPlot2, top_value=rthVWAPLower2 >= ethVWAPLower2 ? rthVWAPLower2 : ethVWAPLower2, bottom_value=rthVWAPLower2 >= ethVWAPLower2 ? ethVWAPLower2 : rthVWAPLower2, top_color=rthVWAPLower2 >= ethVWAPLower2 ? color.rgb(255, 244, 1, 90) : color.rgb(255, 255, 255, 100), bottom_color=rthVWAPLower2 >= ethVWAPLower2 ? color.rgb(255, 255, 255, 100) : color.rgb(255, 244, 1, 90), title="RTH & ETH VWAPs Lower Band #2 Plot Fill")
fill(plot1=lowerRPlot3, plot2=lowerEPlot3, top_value=rthVWAPLower3 >= ethVWAPLower3 ? rthVWAPLower3 : ethVWAPLower3, bottom_value=rthVWAPLower3 >= ethVWAPLower3 ? ethVWAPLower3 : rthVWAPLower3, top_color=rthVWAPLower3 >= ethVWAPLower3 ? color.rgb(255, 244, 1, 90) : color.rgb(255, 255, 255, 100), bottom_color=rthVWAPLower3 >= ethVWAPLower3 ? color.rgb(255, 255, 255, 100) : color.rgb(255, 244, 1, 90), title="RTH & ETH VWAPs Lower Band #3 Plot Fill")