Take the high/low of chart and make the high = 1 and low =0?

I don't think what I'm looking for is compression, but it could be. I want to take the high/low of my scanner and set the high = 1 and the low =0.
If you guys know the proper term for doing this, please let me know.
I don't know if what I am trying to make is a Percentile or if its something else.I honestly don't even know if this is possible. So if it's not, please let me know.

Currently my high is 1.22 and my low is 0.57.
and I can't figure out the proper way to set my High =1, but then my active graph is based on the high and low, so if the high is set to 1 then my graph will definitely need to be compressed.
 
Last edited by a moderator:
What, explicitly, are you attempting to achieve...??? That logic doesn't sound right to me... If you have code, post it... The code, not a shared link...
 
So I made this code, and Its the IV Index and I'm trying to backtest it against some free scanners from another website. the #'s above are the #'s on $ROKU.
I'm trying to make a code to spit out the same stocks, but I'm having trouble with the math part of it.
I want to see how the current IV compares to both the high on the Implied_Volatility_Indicator_High and the Implied_Volatility_Indicator_Low which is what my original question is about. both these scanners are something I'm trying to create and can't figure out the math term for what a am trying to describe.

Code:
#--------------------------------------------------------------
#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"));

But now that I plug in more stocks into this equation, Im getting a very different # for the IV of stocks depending on the website I look at. Did I do something wrong on my graph? like on $FSR on the 1year:1day chart, its showing an implied volatility of 0 until 9/15. and then if I switch the time frame to 3year:1Day it doesn't even show a value until 3/3/2020. Then if you go to Home Depot you can see the IV way back into at least the 1980's. Why is the scanner doing this? Or is it something the data wasn't available for until it suddenly is the graph is made?

I already turned the above code into multiple scanners. Now that I backtest the above scanner against this, I'm having discrepancies between this and my scanner.
Like game stop is showing an Implied Volatility of 285%, but this scanner I made is showing 215%. and then the 52 week high they are showing is the IV from Friday, which seems to completely take out the IV highs from 3/16, which according to mine is 422%
When I made this I tested it against the same website when $BA showed up, my Implied Volatility was matching what the website was saying. So it seems like its hit and miss with what the IV shows on other websites versus mine.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
348 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top