Australian (ASX) Stock Market Forum

Bollinger Band Squeeze Scan/Exploration

Joined
30 November 2008
Posts
27
Reaction score
0
Hello,
Does anyone know where I can get an AFL that gives me the formula for BBSqueeze but would also allow me to scan a list of Canadian stocks? I use EOD data for my trading. Thank you.

Tim
 

pixel

DIY Trader
Joined
3 February 2010
Posts
5,359
Reaction score
333
Hello,
Does anyone know where I can get an AFL that gives me the formula for BBSqueeze but would also allow me to scan a list of Canadian stocks? I use EOD data for my trading. Thank you.

Tim

Hi Tim,
I wrote a script like that; called it "Head Fake",
But it's working under the Market Analyser system from MDSnews, now renamed Sequoia.
The language is PASCAL.
 
Joined
30 November 2008
Posts
27
Reaction score
0
Thank you everyone for your suggestions. While I still haven't found an AFL that would allow me to scan for triangles etc., the BBSqueeze would help me identify some stocks that were worthy of looking at. This is why I am hoping to find an AFL with a scan/explore function with it. It is simply a convenient way to sift through a number of pre-selected stocks.

Tim
 

CanOz

Home runs feel good, but base hits pay bills!
Joined
11 July 2006
Posts
11,534
Reaction score
497
I'm sure I had one at one time....I'll have a look this morning
 

CanOz

Home runs feel good, but base hits pay bills!
Joined
11 July 2006
Posts
11,534
Reaction score
497
I'm sure I had one at one time....I'll have a look this morning

Hmmm no, i have one coded by Radge, but we're not supposed to share the codes. I seem to recall that i saw one on the Amibroker library one time...
 
Joined
24 October 2005
Posts
1,302
Reaction score
832
I seem to recall that i saw one on the Amibroker library one time...

There's a "BB Squeeze" code in the Amibroker library.

Tim, a search for "BB Squeeze" in the library will locate it or a search for the author "Vladimir Gaitanoff". The library is in the members zone now so I'm not sure if we're able to copy the code elsewhere otherwise I'd post it here.
 
Joined
28 December 2015
Posts
14
Reaction score
3
Hi tim, I thought I'd check out this forum. I looked at the User AFL Library BB Squeeze code but it seems based on something very different. He is comparing BBands to Keltner Bands and when the BB are within the KB he defines the squeeze. It's an interesting idea but not what John Bollinger describes.

So I've taken a stab at the code with an exploration and a plot, and I rank the squeeze of you can choose whatever value you want to define "squeeze".

Attached is a screen shot of my version vs the User AFL Library version and they seem at times to be saying very different things. I have no idea which is "better", but mine seems to follow Bollinger's definition.

Good luck.

Larry


// BB Squeeze code

P = ParamField( "Price field", -1 );
Periods = Param( "Periods", 20, 2, 200, 1 ); // lookback period for calculating BB
Width = Param( "Width", 2, 0, 10, 0.05 ); // number of standard deviations for plotting the BB
RankLB = Param( "RankLB", 125, 10, 300, 5 ); // lookback period for squeeze definition

Bandwidth = ( BBandTop( P, Periods, Width ) - BBandBot( P, Periods, Width ) ) / MA( P, Periods ); // Width between top and bottom bands

BWrank = PercentRank( Bandwidth, RankLB ); // a way to rank the current width compared to itself over time

// you can set whatever number you are looking for in terms of
// how tight you want the squeeze, here I put in "10" meaning
// it ranks in the tightest 10 percent of band width over the past "RankLB" days
Condition1 = IIf( BWrank < 10, 1, 0 );

// for exploration here are a few columns to look for
Filter = 1; // all bars
AddColumn( BWrank, "BW Rank", 1.2 );
AddColumn( Condition1, "Condition1", 1.1 );

// Plot(Bandwidth, "Bandwidth", colorGold,styleThick);
Plot( BWrank, "Bandwidth Rank", colorRed, styleOwnScale );
 

Attachments

  • squeeze.PNG
    squeeze.PNG
    52.2 KB · Views: 47
Joined
30 November 2008
Posts
27
Reaction score
0
Thank you, Larry, I appreciate your thoughtfulness. I'm not sure what the exploration is telling me so I need to figure out the indicator and then the scan. When it comes to computers and software I am not the sharpest knife in the drawer...lol. Thank you again.

Tim








Hi tim, I thought I'd check out this forum. I looked at the User AFL Library BB Squeeze code but it seems based on something very different. He is comparing BBands to Keltner Bands and when the BB are within the KB he defines the squeeze. It's an interesting idea but not what John Bollinger describes.

So I've taken a stab at the code with an exploration and a plot, and I rank the squeeze of you can choose whatever value you want to define "squeeze".

Attached is a screen shot of my version vs the User AFL Library version and they seem at times to be saying very different things. I have no idea which is "better", but mine seems to follow Bollinger's definition.

Good luck.

Larry


// BB Squeeze code

P = ParamField( "Price field", -1 );
Periods = Param( "Periods", 20, 2, 200, 1 ); // lookback period for calculating BB
Width = Param( "Width", 2, 0, 10, 0.05 ); // number of standard deviations for plotting the BB
RankLB = Param( "RankLB", 125, 10, 300, 5 ); // lookback period for squeeze definition

Bandwidth = ( BBandTop( P, Periods, Width ) - BBandBot( P, Periods, Width ) ) / MA( P, Periods ); // Width between top and bottom bands

BWrank = PercentRank( Bandwidth, RankLB ); // a way to rank the current width compared to itself over time

// you can set whatever number you are looking for in terms of
// how tight you want the squeeze, here I put in "10" meaning
// it ranks in the tightest 10 percent of band width over the past "RankLB" days
Condition1 = IIf( BWrank < 10, 1, 0 );

// for exploration here are a few columns to look for
Filter = 1; // all bars
AddColumn( BWrank, "BW Rank", 1.2 );
AddColumn( Condition1, "Condition1", 1.1 );

// Plot(Bandwidth, "Bandwidth", colorGold,styleThick);
Plot( BWrank, "Bandwidth Rank", colorRed, styleOwnScale );
 
Joined
30 November 2008
Posts
27
Reaction score
0
Thank you Captain Black for your suggestion, I appreciate it.

Tim




There's a "BB Squeeze" code in the Amibroker library.

Tim, a search for "BB Squeeze" in the library will locate it or a search for the author "Vladimir Gaitanoff". The library is in the members zone now so I'm not sure if we're able to copy the code elsewhere otherwise I'd post it here.
 
Joined
10 May 2017
Posts
3
Reaction score
0
Hi

You can use BB Percentage to find location price in BB ..

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
 
Joined
10 May 2017
Posts
3
Reaction score
0
%B = 1 means that Price is sitting on the Upper Bollinger Band
%B > 1 means that Price has crossed above the Upper Bollinger Band
%B = 0 means that Price is sitting on the Lower Bollinger Band
%B < 0 means that Price has crossed below the Lower Bollinger Band
%B = 0.5 means that Price is sitting on the Middle Band
%B > 0.5 and %B < 1 means that Price is between Upper Bollinger Band and Middle Band
%B < 0.5 and %B > 0 means that Price is between Lower Bollinger Band and Middle Band
 
Joined
10 May 2017
Posts
3
Reaction score
0
Above 1 and below 0 => Can give Squeeze ,
So once your scanner shows greater than 1 or less than 0 => u can find squeeze is occurring or not ..
 

tech/a

No Ordinary Duck
Joined
14 October 2004
Posts
20,045
Reaction score
5,246
Can someone explain to me how a squeeze works
BBs are generally at 20 period M/A
And a displaced 20 Period M/A
So it's lagging

I presume your looking for charts where these 2 M/As are close together and flattish

So if correct then what
If not
 

pixel

DIY Trader
Joined
3 February 2010
Posts
5,359
Reaction score
333
Can someone explain to me how a squeeze works
BBs are generally at 20 period M/A
And a displaced 20 Period M/A
So it's lagging

I presume your looking for charts where these 2 M/As are close together and flattish

So if correct then what
If not
http://acmeanalytics.com/eol/?method=1
It appears even JB himself has given up on the Squeeze assumptions.
About 10 years ago, I wrote a specific script for the squeeze, even allowing for different periods and averages. Backtesting on a range of stocks did not show any edge.
 
Joined
13 December 2015
Posts
492
Reaction score
152
There are much easier ways to measure range compression . Donchian channel width one of the easiest . cant get more basic code ... high over 'x' period minus low over 'x' period , Much easier to code exactly what you want than try and bend some generic into a poor example of what you actually require . Writing custom code will set you free from the constraints of generics .
 
Joined
13 December 2015
Posts
492
Reaction score
152
There are much easier ways to measure range compression . Donchian channel width one of the easiest . cant get more basic code ... high over 'x' period minus low over 'x' period , Much easier to code exactly what you want than try and bend some generic into a poor example of what you actually require . Writing custom code will set you free from the constraints of generics .
PS handy hint while writing code for indicators , I build most of mine to measure as % of price not points/dollars , much more universal and better for comparison between instruments with distinctly different price levels .. Also useful for pattern comparison multi years apart where price has changed dramatically ... Rock on
 

CanOz

Home runs feel good, but base hits pay bills!
Joined
11 July 2006
Posts
11,534
Reaction score
497
I've run BB squeeze code on a ton of things, including futures and FX. Alone its simply not profitable, but as its an indicator of volatility and possibly regime, its still useful. As Quant says though there are now many other ways to determine those useful facts.
 
Top