```
#--------------------------------------------------------------
#Hint: plots the 52 week high and 52 week low Implied Volatility.
#----------------------------------------------------------------------------------
#CODE BELOW
#----------------------------------------------------------------------------------
declare lower;
def high = Imp_Volatility();
def low = Imp_Volatility();
#----------------------------------------------------------------------------------
####Can below Changed to show longer by multiplying # of days (252) by x # of years for longer time frames. Current implied Volatility is also plotted on this chart.
#input 52 week = Highest(high(period = AggregationPeriod.WEEK), 52)
input number_of_days = 252;
def a1 = Highest(high, number_of_days);
def barNumber1 = BarNumber();
def bar1 = if IsNaN(a1)
then Double.NaN
else BarNumber();
def ThisBar1 = HighestAll(bar1);
def Line1 = if bar1 == ThisBar1
then a1
else Double.NaN;
plot P1 = if ThisBar1
then HighestAll(Line1)
else Double.NaN;
P1.SetStyle(Curve.SHORT_DASH);
P1.SetLineWeight(1);
P1.SetDefaultColor(CreateColor(255, 204, 204));
#----------------------------------------------------------------------------------
#def number_of_days = 252; is the same at the top, copy this line when creating an individual scan so the info is connected to the below data/chart.
def a2 = Lowest(low, number_of_days);
def barNumber = BarNumber();
def bar2 = if IsNaN(a2)
then Double.NaN
else BarNumber();
def ThisBar2 = HighestAll(bar2);
def Line2 = if bar2 == ThisBar2
then a2
else Double.NaN;
plot P2 = if ThisBar2
then HighestAll(Line2)
else Double.NaN;
P2.SetStyle(Curve.SHORT_DASH);
P2.SetLineWeight(1);
P2.SetDefaultColor(CreateColor(204, 255, 204));
#----------------------------------------------------------------------------------
def ImpVol = imp_volatility();
#----------------------------------------------------------------------------------
###Hint:type percent as a decimal. 10% = 0.1, 13% = 0.13, 6% = 0.06, etc...
input percent = 0.06;
##ImpVoly = p = ImpVol; system wont let me put P there so its staying as ImpVoly and the Implied volatility graph will be called ImpVoly.
##highs:
#P1= highest high of the current time frame.
#P11= number that is the % from the highest high as specified above.
#P12= actual number that is xyz % below the highest high.
##Low's:
#P2= lowest low of the current time frame.
#P21= number that is the % from the lowest low as specified above.
#P22= actual number that is xyz % above the lowest low.
#----------------------------------------------------------------------------------
def P = ImpVol;
def p11 = percent * p1;
def p21 = percent * p2;
plot p22 = p21 + P2;
P22.SetStyle(Curve.SHORT_DASH);
P22.SetLineWeight(1);
P22.SetDefaultColor(CreateColor(204, 255, 204));
plot p12 = P1 - p11;
p12.SetStyle(Curve.SHORT_DASH);
p12.SetLineWeight(1);
p12.SetDefaultColor(CreateColor(255, 204, 204));
def price = if IsNaN(P) then price[1] else P;
plot ImpVoly = if IsNaN(close) then Double.NaN else price;
ImpVoly.EnableApproximation();
AddCloud(p2, p22, CreateColor(204, 255, 204), CreateColor(204, 255, 204));
##AddCloud(OS, neutral, CreateColor(50, 0, 0), CreateColor(50, 0, 0));
AddCloud(p12, p1, CreateColor(255, 204, 204), CreateColor(255, 204, 204));
ImpVoly.DefineColor("The_High", GetColor());
ImpVoly.DefineColor("Normal", GetColor());
ImpVoly.DefineColor("The_Low", GetColor());
ImpVoly.assignValueColor(if ImpVoly > P12 then ImpVoly.color("The_High") else if ImpVoly < P22 then ImpVoly.color("The_Low") else ImpVoly.color("Normal"));
```