Dealar VIX Implied Range + Retracement Levels
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=4
study("Dealar VIX Implied Range + Retracement Levels", overlay=true)

volatilityindex = input(title="Index", type=input.string, defval="CBOE:VIX")

vix = security(volatilityindex, timeframe.period, open)

highTimeFrame = input("D", type=input.resolution)
sessSpec = input("0830-1500", type=input.session)

is_newbar(res, sess) =>
    t = time(res, sess)
    na(t[1]) and not na(t) or t[1] < t

newbar = is_newbar("1440", sessSpec)
float s1 = na
s1 := newbar ? close : nz(s1[1])
float vixclose = na
vixclose := newbar ? vix : nz(vixclose[1])
float vixpercent = (vixclose / 16) * .01

float highestimate = s1 * (1 + vixpercent)
float high50estimate = s1 * (1 + (vixpercent *.5))
float lowestimate = s1 * (1 - vixpercent)
float low50estimate = s1 * (1 - (vixpercent * .5))
float high75estimate = s1 * (1 + (vixpercent *.75))
float low75estimate = s1 * (1 - (vixpercent * .75))
float high25estimate = s1 * (1 + (vixpercent *.25))
float low25estimate = s1 * (1 - (vixpercent * .25))

plot(highestimate, style=plot.style_circles, linewidth=1, color=color.rgb(64, 66, 75))
plot(lowestimate, style=plot.style_circles, linewidth=1, color=color.rgb(64, 66, 75))
plot(high50estimate, style=plot.style_circles, linewidth=1, color=color.red)
plot(low50estimate, style=plot.style_circles, linewidth=1, color=color.red)
plot(high75estimate, style=plot.style_circles, linewidth=1, color=color.gray)
plot(low75estimate, style=plot.style_circles, linewidth=1, color=color.gray)
plot(high25estimate, style=plot.style_circles, linewidth=1, color=color.rgb(64, 66, 75))
plot(low25estimate, style=plot.style_circles, linewidth=1, color=color.rgb(64, 66, 75))