Bollinger squeeze and divergence
Forums › ProRealTime English forum › ProScreener support › Bollinger squeeze and divergence
- This topic has 12 replies, 4 voices, and was last updated 6 years ago by Petru.
-
-
02/02/2018 at 2:03 PM #61276
Hi,
Sometimes it’s possible to catch good runs and to make some profit when Bollinger bands start to diverge after a squeeze. But as Nicolas and some other members mentioned it is difficult to program this squeeze and divergence. I did some backtesting in excel and the results are kind of OK depends of individual’s expectations. I need your help to write a code to screen the market for opportunities based on my excel spreadsheet.
The difference between upper and lower Bollinger bands must be smaller or equal to the minimum difference between Bollinerg bands over 100 periods multiplied with a constant (e.g. 1.1) (upper Bollinger – lower Bollinger) <= 1.1*min(upper Bollinger – lower Bollinger) over 100 periods . The signal that triggers a ‘buy’ will be given when the bands will start to diverge (current upper Bollinger > previous period upper Bollinger and current lower Bollinger > previous period lower Bollinger) with the price closing above upper Bollinger. To be on the conservative side 7 period moving average should be greater than 23 period moving average. I downloaded a spreadsheet and screenshot.
It is for an uptrend market on a weekly timeframe.
Thank you very much.
Best Regards,
Petru
02/02/2018 at 9:45 PM #6130702/03/2018 at 5:21 PM #61348Hi Petrus,
I tried to make your system, but I can not get the signal of divergence ……. Let’s see if Nicolás can improve it. I leave the indicator so you can see it and tell me where the fault may be.Squeeze -Divergencia Bollinger12345678910111213141516171819202122232425262728BS=BollingerUp(close)BI=BollingerDown(close)BS100=BollingerUp[100](close)BI100=BollingerDown[100](close)DIF=(BI100-BS100)DIFF100= (1.1 *min (DIF,0))MA7=AVERAGE[7](CLOSE)MA23=AVERAGE[23](CLOSE)MMup=MA7>MA23MMdown=MA7<MA23/////////////////////condiTIONS///////////if ((BS-BI) <= DIFF100) AND BS>BS[1] AND BI>BI[1] AND CLOSE>BS AND MMup thendirection = 1elsif ((BS-BI) > DIFF100)AND CLOSE<BI and MMdown thendirection = -1endifif direction > 0 thenbackgroundcolor(10,255,10,100)elsebackgroundcolor(255,10,10,100)endifRETURN BS as "BS",BI AS "BI",BS[1] AS "BS-PAST",BI[1] AS "BI-PAST",MA7 AS "MA7",MA23 AS "MA23",close AS "CLOSE"1 user thanked author for this post.
02/03/2018 at 5:36 PM #6135102/03/2018 at 5:54 PM #61353Here the code without divergences
1234567891011121314151617181920212223242526272829BS=BollingerUp(close)BI=BollingerDown(close)BS100=BollingerUp[100](close)BI100=BollingerDown[100](close)DIF=BS-BIDIF100=(BI100-BS100)MA7=AVERAGE[7](CLOSE)MA23=AVERAGE[23](CLOSE)MMup=MA7>MA23MMdown=MA7<MA23/////////////////////condiTIONS///////////if DIF>DIF100 AND CLOSE>BS AND MMup thendirection = 1elsif CLOSE<BI and MMdown thendirection = -1endifif direction > 0 thenbackgroundcolor(10,255,10,100)elsebackgroundcolor(255,10,10,100)endifRETURN BS as "BS",BI AS "BI",BS[1] AS "BS-PAST",BI[1] AS "BI-PAST",MA7 AS "MA7",MA23 AS "MA23",close AS "CLOSE",bs100 as "BS100",bi100 as "BI100"1 user thanked author for this post.
02/03/2018 at 9:54 PM #61374Thank you and I appreciate very much your help. As I mentioned it is a great forum and people like Nicolas, you and others is keeping it alive. Unfortunately my programming skills are not great but gladly I can share my ideas written in spreadsheets.
02/06/2018 at 10:54 PM #6180502/06/2018 at 11:14 PM #61814ProScreener does not support graphic keywords, like BACKGROUNDCOLOR etc…, just comment them out. The code above is an indicator, you must work a tiny bit on it to convert it to a ProScreener code.
Please attach only .ITF files for import and screenshots for examples or to show issues you may encounter, or at most text files. Avoid attaching .PDF and especially .DOCx files, since many members might not have them installed thus reducing your chances to be helped.
1 user thanked author for this post.
02/07/2018 at 1:47 AM #6182002/07/2018 at 11:00 AM #61840Fr7 has made an indicator for you (thanks to him), not a screener. Here is my own view of your query:
123456789101112bolup=BollingerUp[20](close)boldn=BollingerDown[20](close)diff=bolup-boldnc1 = diff<=lowest[100](diff)*1.1c2 = bolup>bolup[1] and boldn>boldn[1]c3 = close > bolupc4 = average[7]>average[23]test = c1 and c2 and c3 and c4screener[test]Not so much results, c1 condition is very restrictive. Are you sure about c2 (where bolling upper band is superior to its previous one AND the same for the bollinger lower band).
02/07/2018 at 12:24 PM #61853SCREENER Bollinger-Squeeze1234567891011121314151617181920212223242526TIMEFRAME(DEFAULT)BS=BollingerUp(close)BI=BollingerDown(close)BS100=BollingerUp[100](close)BI100=BollingerDown[100](close)DIF=BS-BIDIF100=(BI100-BS100)MA7=AVERAGE[7](CLOSE)MA23=AVERAGE[23](CLOSE)MMup=MA7>MA23MMdown=MA7<MA23/////////////////////condiTIONS///////////if DIF>DIF100 AND CLOSE>BS AND MMup thensignal = 1////BULL SIGNALelsif CLOSE<BI and MMdown thensignal = -1////BEAR SIGNALendifSCREENER (signal AS "signal")02/07/2018 at 12:28 PM #6185902/08/2018 at 4:20 AM #61945Hi Nicolas and Fr7,
Nicolas, you’re right. My conditions are too restrictive and how market behaved in the last few days I don’t have many hits. I have to change a little bit.
Fr7, it is not what I wanted but for sure can be modified and I can use it. I wanted to compare the actual Bollinger difference with minimum (minimal or lowest) difference between bands in the last 100 periods with the same settings, not Bollinger bands with 100 periods as SMA and 2 standard deviations for BS100 and BI100, may be I wasn’t clear in my request
Thank you both of you for your help.
Regards,
Petru
-
AuthorPosts
Find exclusive trading pro-tools on