Bollinger band is an universally used volatility indicator by traders to identify squeeze and breakouts. There are couple of indicators derived out of Bollinger Bands and they are Band Width and Bollinger %B. In Amibroker Formula Language you need to calculate them before using them as there is no inbuilt indicator.
As mentioned above Bollinger BandWidth is an indicator derived from Bollinger Bands and it usually measures the percentage difference between upper and lower bands. Bollinger BandWidth is calculated as follows:
Bollinger BandWidth = (Upper Bollinger Band - Lower Bollinger Band) / Middle Band
Middle Band is usually the Simple Moving Average of the period you have selected and by default its 20 period. You can multiply the above calculated value by 100 to get the percentage.
When the volatility decreases the Bollinger BandWidth value also decreases and therefore it can be used to identify squeeze. Usually the BandWidth value for squeeze can vary and its usually less than 10%. The value depends on the kind of security and you need to understand the behaviour of the security before finalizing the BandWidth value for squeeze. Usually the assumption is that price will make a quick move in either direction after the squeeze.
MA_20 = MA (C,20); //This is the middle line BBTop = BBandTop (Close,20,2); //Upper Bollinger Band BBBottom = BBandBot (Close,20,2); //Lower Bollinger Band BBWidth = ( (BBTop - BBBottom) / MA_20 ) * 100; // Bollinger Band Width Calculation
Bollinger %B is again a derivative of Bollinger band and usually indicates the relative position of the price of the security with respect to the upper and lower Bollinger bands. %B is calculated using the following formulae:
%B = ( Price of the security - Lower Bollinger Band) ________________________________________ (Upper Bollinger Band - Lower Bollinger Band)
Some traders use %B to identify oversold and overbought areas and I personally prefer using %B to identify the breakouts from the Bollinger Band Squeeze.
MA_20 = MA (C,20); //This is the middle line BBTop = BBandTop (Close,20,2); //Upper Bollinger Band BBBottom = BBandBot (Close,20,2); //Lower Bollinger Band PercentB = (Close - BBBottom) / (BBTop - BBBottom); // Bollinger %B indicator Calculation
Note that % can’t be used as the starting char in naming a variable
Please note that above piece of code is for only informational purpose and you need to personally validate and test it before using it