# Widening Bollinger Bands

Good Morning,
I have been using Bollinger Bands on my charts.
The settings I have are 20 periods with a standard deviation of 2.
I have been trying to work out how to write a script that I can put in a scan to identify when the current period has the upper and lower bollinger bands widening. That is, that the gap between them is greater than the gap between them of the previous period on the chart.

Thank you,
Best regards,
Jennifer

Hi Jennifer,

The Vergence() function will be able to produce the results you are after.

Using the same Bollinger Band settings in your post, the following script is one example:

B1 = BB(BARS=20).UpperLine ;

B2 = BB(BARS=20).LowerLine ;

VERGENCE(B1,B2, TYPE=Divergence)

You can adjust the script in increase or decrease the number of consecutive days the lines need to be widening for a positive result (by default it is 2 days).

Green shaded zones are examples of where the script will trigger.

Thanks Mathew,

I want the script to trigger after just 1 period of the band distance being wider.

The default setting of 2 appears to be the least number of days. Is it possible to change it to 1, as I want it to trigger when the lines have widened for 1 day only.

I can change it to more than 2, but 2 seems to be the minimum.

Hi Jennifer,

For a single day youâ€™d use the followingâ€¦

B1 = BB(BARS=20).UpperLine ;

B2 = BB(BARS=20).LowerLine ;

B1 IsUp and B2 IsDown