Skip to content

Instantly share code, notes, and snippets.

@r2k0
Created May 5, 2014 23:16
Show Gist options
  • Save r2k0/b3128a0f7de1f3d1e14a to your computer and use it in GitHub Desktop.
Save r2k0/b3128a0f7de1f3d1e14a to your computer and use it in GitHub Desktop.
IV_Ver3
declare upper;
input period = AggregationPeriod.DAY;
input length = 252;
def ivGapHi = if isnan(imp_volatility(period=period)) then 999999999999 else imp_volatility(period=period);
def ivGapLo = if isnan(imp_volatility(period=period)) then -999999999999 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));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment