How extreme is a Bollinger Band squeeze? |
Post Reply |
Author | |
cudderbean
Regular Joined: 02 Oct 2006 Location: Thailand Posts: 40 |
Post Options
Quote Reply
Topic: How extreme is a Bollinger Band squeeze? Posted: 21 Jan 2018 at 4:54pm |
I want to show a list of codes that I can sort by the number of bars since the Bollinger Bandwidth was tighter/smaller than it is today. The most extreme ones I will then put on a watch list to monitor for breakouts. If someone would kindly help me with this little bit of coding, I will add a Bollinger Squeeze scan to the forum. Upper:= bbandtop(c,20,s,2); Middle:=ma(c,20,s); Lower:=bbandbot(c,20,s,2); BandWidth:= (upper-lower)/middle; bbwextreme := barssince({how many bars ago was the Bollinger Bandwidth was less than/tighter than what it is today}); This {....}is the part I cannot code Thank you for your help.
|
|
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply Posted: 23 Jan 2018 at 10:08pm |
I found that substituting 'middle' with 'lower' indicates bandwidth contraction better, since the middle-line does not contract. So you could base the scan on that custom indicator. A scan for X number of days with the percentage getting lower=contracting, and say 6% or less between the bands can also be found. Verify the following indicator against the bollinger bands on a chart to get a baseline on the values required.
expr := expression("Expression"); method := inputma("Method",SIMPLE); n := input("Time periods",30,1); sd1 := input("Standard Deviations",2,1); top:= bbandtop(expr,n,method,sd1); bot:= bbandbot(expr,n,method,sd1); ((top - bot) / bot) * 100; Edited by maximo - 24 Jan 2018 at 4:25am |
|
cudderbean
Regular Joined: 02 Oct 2006 Location: Thailand Posts: 40 |
Post Options Quote Reply Posted: 26 Jan 2018 at 3:45pm |
Thank you kindly for your help, Maximo. I have actually used Bollinger's standard 20,2 settings only because it may come as default on other users' charts, but taken on board your modified Bandwidth formula. As members may or may not know, you can only have fixed parameters in a Scan itself, unlike indicators. That works fine and gives me a list I can sort by tightest bandwidth. {Variables} top := bbandtop(c,20,s,2); {20 SMA, 2*standard deviations} bot := bbandbot(c,20,s,2); {20 SMA, 2*standard deviations} bbwidth :=((top - bot) / bot) * 100; {modified Bandwidth formula} {Condition} filter := (bbwidth <= 6); {Bandwidth tightened to <=6%} filter; {Columns} [name="BB Bandwidth"; dp="2"] bbwidth; Additional Bandwidth filter But, I am still having difficulty with coding an additional different filter that has baffled me: When (how many bars ago?) was the last time that the Bollinger Bandwidth was even narrower than it is today. I even tried to convert today's bandwidth into an absolute fixed value, but it won't recognise it. bbwtoday := abs(bbwidth*1); prevsqueeze := barssince(bbwidth<bbwtoday); {Variables} top := bbandtop(c,20,s,2); {20 SMA, 2*standard deviations} bot := bbandbot(c,20,s,2); {20 SMA, 2*standard deviations} bbwidth :=((top - bot) / bot) * 100; {modified Bandwidth formula} bbwtoday := abs(bbwidth*1); prevsqueeze := barssince(bbwidth<bbwtoday); {How many bars ago was the Bandwidth even narrower than it is today?} {Condition} filter := (bbwidth <= 6); {Bandwidth tightened to <=6%} filter; {Columns} [name="BB Bandwidth"; dp="2"] bbwidth; [name="Narrowest since"; dp="0"] prevsqueeze; Thank you for your help.
|
|
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply Posted: 27 Jan 2018 at 4:46am |
I'll see what I can do.
Edited by maximo - 28 Jan 2018 at 5:31pm |
|
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply Posted: 28 Jan 2018 at 5:29pm |
I updated the bandwidth indicator with visible numbers to show the output of Barssince(). That may be of help.
Currently it shows a count of the number of barssince the bands were contracting. expr := expression("Expression"); method := inputma("Method",SIMPLE); n := input("Time periods",20,1); sd1 := input("Standard Deviations",2,1); top:= bbandtop(expr,n,method,sd1); bot:= bbandbot(expr,n,method,sd1); bw:=((top - bot) / bot) * 100; bw; Counter:=if(bw>=hist(bw,1),0,barssince(bw>=hist(bw,1))); [color=Black] [linestyle=Text; textalign=Below,Center] If(Counter>0, Right(Counter,2) , undefined); Low; Edited by maximo - 28 Jan 2018 at 5:35pm |
|
Post Reply |
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |