Created
October 3, 2013 13:28
-
-
Save wesyoung/6809837 to your computer and use it in GitHub Desktop.
tos-iv-precentile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################ | |
# sdi_ivp: Display Implied Volatility Percentile as a label | |
#hint: Displays the Implied Volatility Percentile as a chart label. sdi_ivp rev: 1.2 http://www.smallDogInvestor.com | |
# author: allen everhart | |
# date: 19jul2013 | |
# revision 1.2 9/18/2013 | |
# enhancement to permit user to select label color | |
# revision 1.1 9/13/2013 | |
# previously sdi_ivp printed N/A if there were gaps in the imp_volatility data. now gaps are ignored. | |
# copylefts reserved. This is free software. That means you are free | |
# to use or modify it for your own usage but not for resale. | |
# Help me get the word out about my blog by keeping this header | |
# in place. | |
declare upper; | |
input period = AggregationPeriod.DAY ; | |
#hint period: time period to use for aggregating implied volatility. sdi_ivp rev: 1.2 http://www.smallDogInvestor.com | |
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); | |
plot labelColor = 0; # only to pull in color select widget | |
labelColor.setHiding(1) ; #never want to show this | |
labelColor.hideBubble(); | |
labelColor.hideTitle(); | |
labelColor.setDefaultColor(color.PLUM); | |
AddLabel(1, Concat("IV%: ", ivp), labelColor.takeValueColor() ); | |
#################################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment