InvestorsHub Logo
Followers 11
Posts 2529
Boards Moderated 1
Alias Born 04/03/2009

Re: spdpro post# 3039

Sunday, 09/29/2013 6:59:11 PM

Sunday, September 29, 2013 6:59:11 PM

Post# of 3631
Revised your code with pound signs for those that don't know code to get rid of the errors. I'm not seeing a label or anything popping up on the charts however. Have you used this code? I dropped it into a daily chart and left the length at 252 and got nothing. Maybe a shorter time period?

##IV code, implied vol
##
declare upper;
input period = AggregationPeriod.DAY ;
#hint period: time period to use for aggregating implied volatility.
input length =252 ;
#hint length: #bars to use in implied volatility calculation.
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 = CreateColor(255-(ivp*2.55),ivp*2.55,0));

Join the InvestorsHub Community

Register for free to join our community of investors and share your ideas. You will also get access to streaming quotes, interactive charts, trades, portfolio, live options flow and more tools.