SPY Volume Weighted Close
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Steversteves

//@version=5
indicator("SPY Volume Weighted Close", overlay=true)

// Grab data from previous daily candle
ticker = ticker.new(syminfo.prefix, syminfo.ticker, session.regular)
last_hvolume = request.security(ticker, "60", volume[1], lookahead=barmerge.lookahead_on)
today_hopen = request.security(ticker, "60", open, lookahead=barmerge.lookahead_on)


// Color code  

purple_90 = color.new(color.purple, 90)
yellow_90 = color.new(color.yellow, 80)
blue_90 = color.new(color.blue, 80) 


// Volume Weighted Close

o = today_hopen * 0.999 
v = last_hvolume * 2.139E-9 

close_analysis = (o + v) + 0.552 

cl = plot(close_analysis, "Volume Weighted Close", color=color.blue, linewidth=2)


// bands

ucl = close_analysis + 1.45
lcl = close_analysis - 1.45

cl2 = plot(ucl, "Upper Confidence Level VWC", color=color.white)

cl1 = plot(lcl, "Lower Confidence Lvel VWC", color=color.purple)




// Averages

ucltocl = (ucl + close_analysis) / 2 
lcltocl = (lcl + close_analysis) / 2 

// Bools 
bool highvol = close > ucltocl 
bool lowvol = close < lcltocl 
color highvolcolor = highvol ? yellow_90 : purple_90 
color lowvolcolor = lowvol ? blue_90 : purple_90 

// Fills
fill(cl1, cl, color=lowvolcolor, editable=true)
fill(cl2, cl, color=highvolcolor, editable=true)


