SOLANA Performance & Volatility Analysis BB%
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Volatility_Vibes
//@version=5
indicator(title='SOLANA Performance & Volatility Analysis BB%', shorttitle='SOL P&V Analysis BB%', format=format.price, precision=2)

// Inputs
ChartLine = input(title='SOLANA PRICE (SOLUSD)', defval=true)
SOLINVERSE = input(title='SOLANA INVERRSE (SOLUSDT.3S)', defval=true)
SOLVOL = input(title='SOLANA VOLATILITY (SOLUSDSHORTS)', defval=true)
BITCOIN24HVOLATILITY = input(title='BITCOIN 24 HOUR HISTORICAL VOLATILITY(BVOL24H)', defval=false)

// Define variables
res = timeframe.period
source = close

SOLANAINVERSESymbol = input('SOLUSDT.3S')
xInverse = request.security(SOLANAINVERSESymbol, res, source)

SOLANAVOLSymbol = input('SOLUSDSHORTS')
yVolatility = request.security(SOLANAVOLSymbol, res, source)

BVOL24Symbol = input('BVOL24H')
zBTC24HVolatility = request.security(BVOL24Symbol, res, source)

// BB
length = input.int(20, minval=1)
//src = close
mult = input.float(2.0, minval=0.001, maxval=50)

// SOLANA PRICE
basisSOLANAPRICE = ta.sma(close, length)
devSOLANAPRICE = mult * ta.stdev(close, length)
upperSOLANAPRICE = basisSOLANAPRICE + devSOLANAPRICE
lowerSOLANAPRICE = basisSOLANAPRICE - devSOLANAPRICE
normalizedPrice = (close - lowerSOLANAPRICE) / (upperSOLANAPRICE - lowerSOLANAPRICE)
plot(ChartLine ? normalizedPrice : na, color=color.new(color.blue, 0), style=plot.style_stepline, title='Price')

// SOLANA INVERSE
basisSOLANAINVERSE = ta.sma(xInverse, length)
devSOLANAINVERSE = mult * ta.stdev(xInverse, length)
upperSOLANAINVERSE = basisSOLANAINVERSE + devSOLANAINVERSE
lowerSOLANAINVERSE = basisSOLANAINVERSE - devSOLANAINVERSE
normalizedInverse = (xInverse - lowerSOLANAINVERSE) / (upperSOLANAINVERSE - lowerSOLANAINVERSE)
plot(SOLINVERSE ? normalizedInverse : na, color=color.new(color.red, 0), style=plot.style_stepline, title='SOLANA INVERSE')

// SOLANA VOLATILITY
basisSOLANAVOL = ta.sma(yVolatility, length)
devSOLANAVOL = mult * ta.stdev(yVolatility, length)
upperSOLANAVOL = basisSOLANAVOL + devSOLANAVOL
lowerSOLANAVOL = basisSOLANAVOL - devSOLANAVOL
normalizedVolatility = (yVolatility - lowerSOLANAVOL) / (upperSOLANAVOL - lowerSOLANAVOL)
plot(SOLVOL ? normalizedVolatility : na, color=color.new(color.green, 0), style=plot.style_stepline, title='SOLANA VOLATILITY')

// BITCOIN 24HR VOLATILITY
basisBTC24HVOL = ta.sma(zBTC24HVolatility, length)
devBTC24HVOL = mult * ta.stdev(zBTC24HVolatility, length)
upperBTC24HVOL = basisBTC24HVOL + devBTC24HVOL
lowerBTC24HVOL = basisBTC24HVOL - devBTC24HVOL
normalizedBTC24HVolatility = (zBTC24HVolatility - lowerBTC24HVOL) / (upperBTC24HVOL - lowerBTC24HVOL)
plot(BITCOIN24HVOLATILITY ? normalizedBTC24HVolatility : na, color=color.new(#ffffff, 0), style=plot.style_stepline, title='BITCOIN 24HR VOLATILITY')

// Plot bands
band1 = hline(0.80, color=color.red, linestyle=hline.style_dashed)
band2 = hline(0.60, color=color.gray, linestyle=hline.style_dashed)
band3 = hline(0.40, color=color.gray, linestyle=hline.style_dashed)
band4 = hline(0.20, color=color.red, linestyle=hline.style_dashed)
fill(band2, band3, color=color.new(color.teal, 90))

