NexusFi: Find Your Edge


Home Menu

 





Thinkorswim custom script for Stock/ETF / volatility percent percentile range


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one alchemist74 with 2 posts (3 thanks)
    2. looks_two rmejia with 2 posts (0 thanks)
    3. looks_3 contrails with 2 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 23,081 views
    2. thumb_up 5 thanks given
    3. group 9 followers
    1. forum 11 posts
    2. attach_file 1 attachments




 
Search this Thread

Thinkorswim custom script for Stock/ETF / volatility percent percentile range

  #11 (permalink)
loadup
singapore
 
Posts: 1 since Nov 2013
Thanks Given: 1
Thanks Received: 1


alchemist74 View Post
Hi,
sorry i delayed my answer but i trade very heavily last few months. I find better TOS code for IV rank, here it is:

def vol = imp_volatility;
#rec data = if !isNaN(vol) then vol else data[1];
def data = vol;
def hi = highest(data,252);
def lo = lowest(data,252);
def perct = round((data - lo)*100/ (hi - lo),0);
plot x = perct;
plot H = 90;
plot L = 20;

this will draw a line tool bellow your chart . If u want to see just a number at your left chart corner use this:

declare upper;
input period = AggregationPeriod.DAY ;

input length =252 ;

def ivGapHi = if isnan(imp_volatility(period=period)) then 99999999999 else imp_volatility(period=period);
def ivGapLo = if isnan(imp_volatility(period=period)) then -99999999999 else imp_volatility(period=period);
def periodHigh = highest( ivGapLo,length=length);
def periodLow = lowest( ivGapHi, length=length);
def ivRange = periodHigh - periodLow ;
def ivp = round( 100*(imp_volatility(period=period) - periodLow)/ivRange, 0);
AddLabel(1, Concat("IV%: ", ivp), color = Color.PLUM);

Thank u Alchemist74, created an account just to thank u. The code is just what i needed.

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Quant vue
Trading Reviews and Vendors
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
How to apply profiles
Traders Hideout
Better Renko Gaps
The Elite Circle
 
  #12 (permalink)
nicoan
Bahia Blanca + Buenos Aires/Argentina
 
Posts: 1 since Sep 2013
Thanks Given: 0
Thanks Received: 0


alchemist74 View Post
def vol = imp_volatility;
#rec data = if !isNaN(vol) then vol else data[1];
def data = vol;
def hi = highest(data,252);
def lo = lowest(data,252);
def perct = round((data - lo)*100/ (hi - lo),0);
plot x = perct;
plot H = 90;
plot L = 20;

Alchemist, when there is at least one missing day in the IV within the last 252 trading days the whole study breaks.

I see you started to address the issue here on the commented line:

#rec data = if !isNaN(vol) then vol else data[1];

Have you fixed it? I cannot believe that they havenīt fixed it yet on TOS. The scanner, columns and studies.. all with the same problem. As if they wanted to have it that way..

I think this happens because of the division by 0 here:
def perct = round((data - lo)*100/ (hi - lo),0);

If there is just one missing day, the hi and the lo will be 0, so there will be a division by zero in the formula and that will break the study.

I think we could solve it if we can ignore the 0. I came up with a logic like this:


def hi = If (vol = 0, [use the highest between 0.1 and the high], else highest(vol,252);

def lo = If (vol = 0, [use the lowest between 0.1 and the low], else lowest(vol,252);


But I donīt know how to code it.

What do you think?

Can anyone help me fix it so that it works even if there are missing days in the IV in the last year?

Reply With Quote




Last Updated on January 19, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts