XS
SM
MD
LG
XL

Cool Scripts: Bollinger Band-ing Volatility

Learn how to create a thinkScript in thinkorswim by TD Ameritrade using Bollinger Bands to generate possible trading signals

Print
https://tickertapecdn.tdameritrade.com/assets/images/pages/md/Bollinger Bands
3 min read

Volatility may not tell you which way is up, but it can point to possible trading signals. Let’s create a thinkScript® in TD Ameritrade's thinkorswim® trading platform that uses Bollinger Bands to simultaneously analyze price and implied volatility to generate possible trading signals.

Our goal? Let’s have thinkorswim color a price bar a different color when the implied volatility of the underlying is outside its own set of Bollinger bands—covering 95% of volatility’s normal range of movement, or in geek-speak, two standard deviations. The indicator is designed to point out time where a trader may want to get long (below the lower band), or short (above the upper band) volatility.

The Script*

Cut and paste each of the following lines into your Script editor. But be sure not to include the line numbers.

1. #Hint: Bollinger Bands for IV

2. declare lower;

3. declare hide_on_intraday;

4. input length = 10;

5. input NumberofDevs = 2;

6. def data = ImpVolatility();

7. def up = close > open;

8. def down = close < open;

9. def offset = NumberofDevs * Stdev(data, length);

10. #The plots that will be drawn on the chart

11. plot IV = data;

12. plot MidLine = Average(data, length);

13. plot UpperBand = MidLine + offset;

14. plot LowerBand = MidLine - offset;

15. #Changing the color of the chart to make it pop and significant time

16. AssignPriceColor(if data > upperBand and down then Color.YELLOW else if data < lowerBand and up then color.BLUE else color.current);

The Skinny

Line 1. Recall that the hash tag “#” creates a note in your script to create hints or to keep track of what you’re coding.

Line 2-3. Next, two declarations. Declaring something applies to how the script can or should be used. In this case, we declare this a lower study, and also hide this on any intraday aggregation.

Line 4. Length defines how many periods should be used to calculate average and standard deviation.

Line 5. NumberofDevs defines the number of standard deviation moves the band will be drawn away from the implied vol.

Line 6. We’re defining our data as implied volatility. You can also define up-price bars and down-price bars to be used later.

Lines 7-9. This is perhaps the most important piece of the script, the logic on which Bollinger Bands are based.

Lines 11-14. Here is where we tell the script what to plot. The Midline is simply the average of what we define as data (implied volatility) for our chosen number of periods, then we add the upper and lower bands of the Bollinger band.

Line 16. The kicker. This line checks if the implied vol is above or below the bands around the average. It also monitors if significant moves are on down-price moves or up-price moves. If there’s an increase in implied vol and the price moves up, the bar is painted yellow. If implied volatility is above the upper band on a down move, the bar is painted blue. This draws your attention to a point you can define as important. Normally, when a price moves down, implied volatility increases. So an up move in price, above when implied volatility is out of its normal range, indicates a price trend could be changing. This same idea translates to a down move in price when implied volatility remains lower than normal. 

undefined

FIGURE 1: BOLLINGERS ON VOLATILITY.

This cool script turns the first bars a custom color after a breach of extreme volatility. For illustrative purposes only. 

*Script Share

Skip the coding yourself and download David’s thinkScript straight into thinkorswim.

 

Call Us
800-454-9272
adChoicesAdChoices

Market volatility, volume, and system availability may delay account access and trade executions.

Past performance of a security or strategy does not guarantee future results or success.

Options are not suitable for all investors as the special risks inherent to options trading may expose investors to potentially rapid and substantial losses. Options trading subject to TD Ameritrade review and approval. Please read Characteristics and Risks of Standardized Options before investing in options.

Supporting documentation for any claims, comparisons, statistics, or other technical data will be supplied upon request.

The information is not intended to be investment advice or construed as a recommendation or endorsement of any particular investment or investment strategy, and is for illustrative purposes only. Be sure to understand all risks involved with each strategy, including commission costs, before attempting to place any trade. Clients must consider all relevant risk factors, including their own personal financial situations, before trading.

This is not an offer or solicitation in any jurisdiction where we are not authorized to do business or where such offer or solicitation would be contrary to the local laws and regulations of that jurisdiction, including, but not limited to persons residing in Australia, Canada, Hong Kong, Japan, Saudi Arabia, Singapore, UK, and the countries of the European Union.

TD Ameritrade, Inc., member FINRA/SIPC. TD Ameritrade is a trademark jointly owned by TD Ameritrade IP Company, Inc. and The Toronto-Dominion Bank. © 2018 TD Ameritrade.

Scroll to Top