FalconRed VIX
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © falcon_red

//@version=5
indicator("FalconRed VIX", overlay=true, linktoseries=true)
timeframeInput = input.string("5", "Timeframe", ["1", "3", "5", "15", "6h", "D", "W", "M", "Y"])
price = request.security(syminfo.ticker, timeframe.period, close)
indiaVix = request.security('INDIAVIX', timeframe.period, close)
factor =  (timeframeInput == "D") ? (indiaVix/math.sqrt(365)/100) : (timeframeInput == "6h") ? (indiaVix/math.sqrt(1461)/100) : (timeframeInput == "Y") ? (indiaVix/math.sqrt(1)/100) : (timeframeInput == "M") ? (indiaVix/math.sqrt(12)/100) : (timeframeInput == "W") ? (indiaVix/math.sqrt(52)/100) : (timeframeInput == "1") ? (indiaVix/math.sqrt(105120)/100) : (timeframeInput == "3") ? (indiaVix/math.sqrt(175200)/100) : (timeframeInput == "5") ? (indiaVix/math.sqrt(105120)/100) : (timeframeInput == "15") ? (indiaVix/math.sqrt(35040)/100) : (indiaVix/math.sqrt(365)/100)
// factor = (indiaVix/math.sqrt(105120)/100)
lower = price * (1 - factor)
upper = price * (1 + factor)

plot(lower, color = color.green, style = plot.style_line)
// plot(price, color = color.black, style = plot.style_line)
plot(upper, color = color.red, style = plot.style_line)
