Combining the Historical and Implied Volatility into a Single Study
Free indicator included, linked below. Plot both the Historical and Implied Volatility together in the same subgraph of a stock chart. Clearly see where crossovers occur. Use this free indicator in a custom scan. Step-by-step instructions in the video show how to run three different kinds of scans from this one indicator. One of the three scans can be used as a pre-earnings scan. This can help you locate stocks where implied volatility is spiking ahead of an expected event, such as earnings, pending court settlements, or pending drug trials.
Use the link below to download this free indicator to your computer. For instructions on how to install it, look for the video titled “Thinkorswim Display Name of Saved Chart“. The instructions begin at the 4:28 mark.
Here is a link to download this free indicator:
Lean More:
Would you like to learn how to master the custom scan tools on Thinkorswim?
Click here: Thinkorswim Scans Beginner to Advanced
Learn how to build custom scans without writing any code: Thinkorswim Condition Wizard
DISCLAIMER: I AM NOT A CERTIFIED FINANCIAL ADVISOR AND NOTHING IN THIS VIDEO OR TEXT IS AN ADVERTISEMENT OR RECOMMENDATION TO BUY OR SELL ANY FINANCIAL INSTRUMENT. NOR IS THIS VIDEO OR TEXT INTENDED TO INSTRUCT YOU ON HOW TO MAKE BUY OR SELL DECISIONS USING ANY OF THESE INDICATORS.
*Thinkorswim is a chart analysis platform offered by TD Ameritrade: www.tdameritrade.com
TD Ameritrade provides financial services including the trading of Stocks, Futures, Options and Forex.
Please be sure to share this page with your friends and colleagues. Leaving comments below is the best way to help make the content of this site even better.
Watch the video, Thinkorswim Historical Implied Volatility below:
Here is an updated version of the chart study which has already been configured to work as a scan. Seems that there are some additional steps required by the current version of Thinkorswim which were not required at the time this video was published.
# This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
# Author: Pete Hahn (Hahn-Tech, LLC)
# tutorial video: https://www.hahn-tech.com/thinkorswim-historical-implied-volatility/
declare lower;
declare hide_on_intraday;
input length = 20;
input basis = {default Annual, Monthly, Weekly, Daily};
input volatilitySpreadMultiplier = 2.0;
def ap = getAggregationPeriod();
Assert(ap >= AggregationPeriod.MIN, "Study can only be calculated for time-aggregated charts: " + ap);
def barsPerDay = (RegularTradingEnd(getYyyyMmDd()) - RegularTradingStart(getYyyyMmDd())) / ap;
def barsPerYear =
if ap > AggregationPeriod.WEEK then 12
else if ap == AggregationPeriod.WEEK then 52
else if ap >= AggregationPeriod.DAY then 252 * AggregationPeriod.DAY / ap
else 252 * barsPerDay;
def basisCoeff;
switch (basis) {
case Annual:
basisCoeff = 1;
case Monthly:
basisCoeff = 12;
case Weekly:
basisCoeff = 52;
case Daily:
basisCoeff = 252;
}
def clLog = log(close / close[1]);
def wklyPrctMove = round( ( highest(high, 5) - lowest(low, 5) ) / lowest(low,5), 3) * 100;
def mthlyPrctMove = round( ( highest(high, 21) - lowest(low,21) ) / lowest(low,21), 3) * 100;
def impVol = IMP_VOLATILITY();
def hv = stdev(clLog, length) * Sqrt(barsPerYear / basisCoeff * length / (length - 1));
# to use in scan mode, place '#' in front of these two plot statements
def impVolLine = impVol;
def histVolLine = hv ;
def doubleVolSpread = impVol > hv * volatilitySpreadMultiplier;
def signal = doubleVolSpread and highest(doubleVolSpread[1], 10) < 1;
def check = impVol != Double.NEGATIVE_INFINITY;
def check2 = impVol != Double.POSITIVE_INFINITY;
# use ONE of these three plot statements in scan mode. After commenting out
# the two plot statments above, select one of the three below and remove the
# '#' symbol from in front of the plot statment
# use this to find stocks where Implied Vol has reached two times Hist Vol
plot scan = if signal and check and check2 then 1 else Double.NaN;
# use this to find stocks where Implied Vol has crossed above Hist Vol
#plot scan = impVol > hv and impVol[1] < hv[1] and check and check2;
# use this to find stocks where Implied Vol has crossed below Hist Vol
#plot scan = impVol < hv and impVol[1] > hv[1] and check and check2;
Do you have a script for options open interest and or volume at strikes?
Not only do I not have anything by that description but I do not think anything like this would be possible for a chart study on Thinkorswim. You will have to view and aggregate those data points manually from the options chain on the Trade tab of Thinkorswim.
Good morning. Is there a way to use the imp/hist vol on a 5 min chart? 2 seperate indicators take up too much room. Also should the basis be set to annuall ? A volume per minute would also be really good
1. To allow this study to display on intraday chart, remove or comment out the following line of code: declare hide_on_intraday;
2. The “Basis” was copied from the built-in chart study named “HistoricalVolatility”. Refer to the documentation provided with that chart study.
3. I have no plans to modify this any further by adding new plots or features.
Beautiful. Thanks works awesome!
When I remove () it creates other codes
I did not say to remove only the parenthesis. I said to to remove the entire AddLabel() statements. Don’t worry, I just updated this page to include a section of code which will work as a scan without any further modifications. Just refresh the page and you should see the code immediately below the video.
Yes. The original script.
Works good on daily thanks. Ran script identical to the one you did but still says add says add label not allowed.
So…. did you remove the AddLabel() statement?
It seems that when this video was published, the AddLabel() statement did not create any errors when applying the script to a scan. Now that it does, simply remove them.
Hi:
I love this study! How would I use this in a watchlist? ie: Iv/hv is greater than 1?
Any code you use for a scan can be applied to a custom watchlist column without modifications. It will display 1’s where the selected scan signal is true and 0’s where the selected scan signal is false.
In order to create a scan signal that fits your request, you can update the following scan signal:
#plot scan = impVol > hv and impVol[1] < hv[1] and check and check2;
and change it to this:
plot scan = impVol > hv and check and check2;
Then add a comment symbol, "#", in front of the first scan signal because only one plot statement can be active at one time.
hi, when i try and run a scan it says add label is not allowed. any suggestions?
Seems as though you missed some important details from the video. Go back and watch that section of the video again so you can see what adjustments are required to get it to work as a scan.