The Bollinger Bands are already present on every platform, but using Bandwidth, the bands will be displayed only when the volatility decreases (during periods of “congestion” or during a range-bound market).
I sometimes use this filter in mean-reverting strategies to avoid signals when volatility is low. This simple correction generally improves breakout strategies.
Firstly, we will use the Bollinger Bandwidth function which measures the BandWidth and thus the volatility of a given financial instrument.
We begin to draw the Bollinger Bands with simple code, slightly different from what you find on the platform:
After that, we have to code the slow and fast Bandwidth and its moving average:
The result will be the distance between the bands. However, we do not just need the distance, so we’ll have to compare a fast Bandwidth with a slower one. In this example, we use a 50-period moving average.
If volatility increases the Bandwidth stays above its moving average.
In addition, we insert the fast Bandwidth above the slow Bandwidth so you can have four types of volatility already usable:
The indicator will draw congestions like this:
HOW TO MAKE THE BOLLINGER BANDS TRANSPARENT
To display the Bollinger Bands BandWidth only during the phases of decreasing volatility, I used the Argb function.
With this function, we can define the colors in Easylanguage for only TradeStation and have much more flexibility than the few preset colors.
The code looks like this:
In short, replace the first and the last value with a 0 and the color becomes transparent.
DOWNLOAD LINK: Indicator for TradeStation
MORE FROM FINANCE STRATEGY SYSTEM
BOLLINGERBANDS.COM: What are Bollinger Bands?