Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save PaulMiami/55488817bb80f5a1000291782558d270 to your computer and use it in GitHub Desktop.
Save PaulMiami/55488817bb80f5a1000291782558d270 to your computer and use it in GitHub Desktop.
IV_RANK
-----
-- By Robert Heatwole
1) Go to 'Charts' tab
2) Click on the "eye-dropper" icon (officially called "edit studies icon"...same line where you type in the ticker same symbol, first icon moving left to right)
3) Click on "New"... Lower left hand corner
4) Delete everything in the box. (plot Data = close;)
5) Paste the entire code listed below
6) Name the study RankLevels
7) Click 'OK'
8) Click 'Apply'
9) Click 'Ok'
-----
declare lower;
declare hide_on_intraday;
#IVPercentile
def vol = imp_volatility();
input DisplayIVPercentile = yes;
input DisplayImpVolatility= yes;
input DisplayDaily1StandardDev = yes;
input DisplayWeekly1StandardDev = yes;
input DisplayMonthly1StandardDev = yes;
input TimePeriod = 252;
def data = if !isNaN(vol) then vol else vol[-1];
def hi = highest(data, TimePeriod);
def lo = lowest(data, TimePeriod);
plot Percentile = (data - lo) / (hi - lo) * 100;
def lowend = Percentile < 25;
def highend = Percentile > 50;
#Labels
addlabel(DisplayIVPercentile , concat("IV Rank: ",aspercent(Percentile /100)), if lowend then color.red else if highend then color.green else color.yellow);
addlabel(DisplayImpVolatility, concat("ImpVolatility: ",aspercent(vol)), if lowend then color.red else if highend then color.green else color.yellow);
def ImpPts = (vol / Sqrt(252)) * close;
AddLabel(DisplayDaily1StandardDev , Concat("Daily 1 SD +/- $", Astext( ImpPts, NumberFormat.TWO_DECIMAL_PLACES)), if lowend then color.red else if highend then color.green else color.yellow); ;
def ImpPts2 = (vol / Sqrt(52)) * close;
AddLabel(DisplayWeekly1StandardDev, Concat("Weekly 1 SD +/- $", Astext( ImpPts2, NumberFormat.TWO_DECIMAL_PLACES)), if lowend then color.red else if highend then color.green else color.yellow); ;
def ImpPts3 = (vol / Sqrt(12)) * close;
AddLabel(DisplayMonthly1StandardDev, Concat("Monthly 1 SD +/- $", Astext( ImpPts3, NumberFormat.TWO_DECIMAL_PLACES)), if lowend then color.red else if highend then color.green else color.yellow); ;
plot LowVol = 25;
plot HighVol = 50;
LowVol.SetDefaultColor(GetColor(5));
HighVol.SetDefaultColor(GetColor(6));
-----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment