IV Percent Change Watchlist for ThinkorSwim

Brain Monkey

New member
On the watchlist if you click customize you can add columns like market cap price what ever. I want a custom column that shows the percent change in implied volatility from the day before. This way when I run a scan I can rank the results by the biggest change in IV from the day before. I tried cobbling a script from other studies and I tried googling for answers. But this one has me. And I'm a little slow. Thank you!
 
@Brain Monkey Here is an IV Percent Change Watchlist that a friend gave me years ago. I just tested it on my watchlist, seems to work fine. Remember to select daily aggregation when you set up the watchlist

Code:
# IV Percent Change Watchlist
# Paris
# 12.07.2015

# Displays IV percentage change over the previous period in a Watchlist column
# Make sure you set the Aggregation to Daily. If you are not getting a value or it displays NaN, then there is no data.

def IV = Imp_Volatility();
plot R = IV / IV[1];

# End Study
 
Last edited:

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

Ok tweeked the math a little. Now it comes out as a percentage.
Code:
def IV = imp_volatility();
plot R = 100*((IV / IV[1]) - 1);
Now is there a way to get a percentile mark next to each number in the same way that % change for price has a % next to each number and is there a way to make the positive numbers green and the negative numbers red?
 
@Brain Monkey The only way you'll be able to force a "%" symbol is to use AddLabel, see if this is close to what you're asking for. I have also tweaked the color scheme per your request

Code:
def IV = Imp_Volatility();
def R = ((IV / IV[1]) - 1);
AddLabel(1, AsPercent(R), if R > R[1] then Color.Green else Color.Red);
 
Ok so now I have the column. When I click on the column so that the results of the scan will show the results with the greatest change in IV. The script has this weird logic where it places the results in almost alphabetical order. So if I click on it to show the stocks that have gone down the most compared to the last day, it thinks the order should be: -0.007; -1.654; -11.52; -2.54; 22.71; -3.5. It's like it's using alphabet logic not placing the numbers on a number line and showing me them in order. God I hope this makes sense because I am so lost right now.
 
Yep, that's the entire issue if you use AddLabel, when you click on it it would not sort numerically. In order to sort numerically you'll need to use a plot statement like you did before. However in so doing you would not be able to retain the trailing "%" symbol.
 
@Brain Monkey The only way you'll be able to force a "%" symbol is to use AddLabel, see if this is close to what you're asking for. I have also tweaked the color scheme per your request

Code:
def IV = Imp_Volatility();
def R = ((IV / IV[1]) - 1);
AddLabel(1, AsPercent(R), if R > R[1] then Color.Green else Color.Red);
@tomsk so this is IV change over 30 days?
 
posting the tos: links is really helpful for non-coders like me :)

@Brain Monkey Here is an IV Percent Change Watchlist that a friend gave me years ago. I just tested it on my watchlist, seems to work fine. Remember to select daily aggregation when you set up the watchlist

Code:
# IV Percent Change Watchlist
# Paris
# 12.07.2015

# Displays IV percentage change over the previous period in a Watchlist column
# Make sure you set the Aggregation to Daily. If you are not getting a value or it displays NaN, then there is no data.

def IV = Imp_Volatility();
plot R = IV / IV[1];

# End Study
can you please post the tos: links for non-coders link me:). ty
 
Hi,

I have imported this IV Percentile (current IV vs. "normal" IV) watchlist column study : http://tos.mx/6IlMBw. But it shows either NaN or Error value in column. Can you please check if something is wrong with the script?
1755669143713.png
 
Hi,

I have imported this IV Percentile (current IV vs. "normal" IV) watchlist column study : http://tos.mx/6IlMBw. But it shows either NaN or Error value in column. Can you please check if something is wrong with the script?

next time, post the code and a link where it came from

its near impossible to debug a bad column study.
copy the code and make a lower chart study.
then add a line and a bubble to display some variables.


lower chart study for debugging
Code:
#iv_per_col02_lower

# col
#iv_per_col02
#https://usethinkscript.com/threads/iv-percentile-watchlist-column.21441/
#IV Percentile watchlist column
#AlwaysLearning  8/20

#I have imported this IV Percentile (current IV vs. "normal" IV) watchlist column study 
#http://tos.mx/6IlMBw
#But it shows either NaN or Error value in column. Can you please check if something is wrong with the script?

declare lower;

input tradingDays = 252;
#input period = AggregationPeriod.DAY;

#def IV = if !IsNaN(imp_volatility(period = period))
#         then imp_volatility(period = period)
def IV = if !IsNaN(imp_volatility())
         then imp_volatility()
         else IV[1];

def IVperc = fold i = 0 to tradingDays
             with p = 0
#             do if IV < GetValue(IV , -i, tradingDays) 
             do if IV < GetValue(IV , -i) 
                then IVperc[1] + 1 
                else IVperc[1];

def normal_IV =  fold j = 0 to tradingDays
               with q = 0
               do if 1 == 1
                then normal_IV[1] + 1 
                else normal_IV[1];

plot IVpercentile = IVperc / (tradingDays + 1);


plot z = 0;

addchartbubble(1, 0,
iv + "\n" +
IVperc + "\n" +
normal_IV + "\n" +
IVpercentile  + "\n" 
, color.yellow, no);

#AssignBackgroundColor (if IVpercentile < 0.35 then color.GREEN else if IVpercentile > 0.70 then color.RED else color.LIGHT_GRAY);
#


when i loaded this as a lower study, the white circle with the ! appeared in the top left of chart.
(252) getvalue: dynamic offset cannot exceed max offset

Code:
def IVperc = fold i = 0 to tradingDays
             with p = 0
             do if IV < GetValue(IV , -i, tradingDays)
                then IVperc[1] + 1
                else IVperc[1];

i never use the 3rd parameter on getvalue.

i removed it, from this
. do if IV < GetValue(IV , -i, tradingDays)
to this
. do if IV < GetValue(IV , -i)
and my lower plotted data


i removed the 3rd parameter ( and the 2nd agg DAY stuff) in the column code and it worked.


ps
1. you dont need 2nd aggregation . just specify DAY time in the column config window

2. you didn't specify a color for the plot. in a column, this will be the font color. my numbers were white, hard to read. i added a black color


column code
Code:
# HINT: This IV percentile is NOT a 0 - 100 rank of where current IV is located within the 52-week high/low range for ImpVolatility.  Instead this IV percentile compares 52-weeks of ImpVolatility data to determine where current IV is located relative to "normal" ImpVolatility.
# Many times IV percentile rank will be same or similar to IV percentile, however, if there has been a spike high or spike low in the ImpVolatility high/low range that spike(s) can skew IV percentile rank causing current IV to appear lower or higher than actual realtive to "normal" IV

input tradingDays = 252;
#input period = AggregationPeriod.DAY;

def IV = if !IsNaN(imp_volatility())
         then imp_volatility()
         else IV[1];

def IVperc = fold i = 0 to tradingDays
             with p = 0
#             do if IV < GetValue(IV , -i, tradingDays)
             do if IV < GetValue(IV , -i)
                then IVperc[1] + 1
                else IVperc[1];

def normal_IV =  fold j = 0 to tradingDays
               with q = 0
               do if 1 == 1
                then normal_IV[1] + 1
                else normal_IV[1];

plot IVpercentile = IVperc / (tradingDays + 1);
IVpercentile.setdefaultcolor(color.black);

AssignBackgroundColor (if IVpercentile < 0.35 then color.GREEN else if IVpercentile > 0.70 then color.RED else color.LIGHT_GRAY);
#
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
1081 Online
Create Post

Similar threads

Similar threads

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