Bollinger Band Squeeze with RSI Divergence

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #28333 quote
    sincitytrader
    Participant
    Junior

    Hi

    I am looking for some assistance on creating a high ‘A quality’ setup for proscreener  to do the following Bollinger Band squeeze with RSI divergence trades.

    See the video here after the 6 minute marker, which explains the trading strategy. https://www.youtube.com/watch?v=7PY4XxQWVfM&list=TLUTNeV0_uFOc

    I have created some code (far from perfect) to detect the boll squeeze and a trigger bar outside the upper bollinger (see below),  but need RSI divergence detected which is inline with the relevant candles for the swing pivot ighs.  So for example, when price makes a higher high, and RSI makes a lower high, go short.

    I have looked at the platform RSI divergence indicators and also the RSX indicator Nicholas created here (https://www.prorealcode.com/prorealtime-indicators/divergences-rsx/),, but the coding is beyond my knowledge.

    Anyone up for a challenge.

    Thanks

    Rob

    // This detects before a potential breakout or breakdown with RSI divergence
    // Bollinger band squeeze increases the quality of breakout trade
    // Go Long
    
    // stocks higher than $10
    c1 = close > 10
    
    // average volume higher than 10k
    c2 = volume > 10000
    
    // identify upward trend price above 20MA
    c3 = average[20](close[2]) > average[20](close[12])
    
    // recent average bollinger bandwidth must be squeezed
    recentboll = average[10](bollingerbandwidth[20](close[2]))
    pastbollbandwidth = average[20](bollingerbandwidth[20](close[2])) - recentboll
    
    c4 = (recentboll < pastbollbandwidth)
    
    
    // over sold trigger bar moving outside upper bollinger band
    c5 = high[3] > BollingerUp[20][3]
    c6 = open[3] < BollingerUp[20][3]
    
    screener [c1 and c2 and c3 and c4 and c5 and c6 ]
    Frode André Isene and Hans64 thanked this post
    #28377 quote
    Nicolas
    Keymaster
    Master

    Interesting strategy because it has sense.  The problem here is that you need 3 conditions that could not appear all at the same time:

    • piercing of the bollinger bands
    • a BB squeeze
    • an RSI divergence

    So to give an effective signal that compile all of these informations, we must define first a “lookback window” for these conditions to be true within these periods.

    How much bars in the past from the current candlestick do you want to go back in the past to find if these conditions were fulfilled?

    #28380 quote
    sincitytrader
    Participant
    Junior

    Hi Nicolas,

    Thanks for your fast response.

    For daily timeframe,  the bollinger band squeeze would need to be decreasing over say, 12-15 bars.  Within this band, would need to see the 2 swing highs with the higher high.   And inline with the 2 highs of the candles that are touching or piercing the upper bollinger, to compare the RSI values at this point.  The 2nd candle to pierce the upper bollinger and see a quick rejection would be preferable,  but not absolutely necessary, so an OR maybe good here.

    Entry would be on price action and a close of a bar closing lower than the previous 2-3 bars or even a doji.

    This could be used on the 4 hourly and 1 hourly time frame.  May need to configure the look back periods for the boll band squeeze.

    Many thanks

    Rob

    #28411 quote
    Nicolas
    Keymaster
    Master

    This is the code for a complete screener that catch these conditions, from my own view. Only the bearish trades opportunity is coded. You need to test it by yourself! I modified the squeeze condition with a Bollinger Bands contained into a keltner channel instead.

    // stocks higher than $10
    c1 = close > 10
    
    // average volume higher than 10k
    c2 = volume > 10000
    
    // identify upward trend price above 20MA
    c3 = average[20](close[2]) > average[20](close[12])
    
    // recent average bollinger bandwidth must be squeezed
    UpperKC = average [20](close) + 1.5*averagetruerange[20](close)
    LowerKC = average [20](close) - 1.5*averagetruerange[20](close)
    
    c4 = summation[3](BollingerUp[20](close) < UpperKC and bollingerdown[20](close) > LowerKC)=3
    
    // over sold trigger bar moving outside upper bollinger band
    c5 = summation[3](high crosses over bollingerup[20])>0
    
    //RSI divergences screener
    //--- parameters
    period = 14 //RSI period
    overbought = 70 //overbought RSI level
    
    //-------------------
    myRSI = RSI[period]
    y=average[2](myRSI)
    // ----
    if intradaybarindex=0 then
    res=0
    endif
    if myRSI>overbought then
    hi=max(hi,myRSI)
    hico=max(hico,max(high,high[1]))
    endif
    if myRSI crosses under y then
    rsi2b=rsi1b
    rsi1b=hi
    hi=0
    p3b=p1b
    p2b=max(p1b,hico1)
    p1b=max(highest[3](high),hico)
    if p2b=p1b then
    p2b=max(p3b,p4b)
    endif
    hico=0
    hico1=0
    endif
    if myRSI<y then
    p4b=hico1
    hico1=max(hico1,high)
    endif
    divBaissiere= p1b>p2b and rsi1b<rsi2b and myRSI crosses under y and myRSI<myRSI[1]
    
    if divBaissiere then
    res=1
    endif
    
    c6 = summation[12](res)>0
    
    screener [c1 and c2 and c3 and c4 and c5 and c6]
    GraHal, Hans64, Gianluca and RubberToe thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Bollinger Band Squeeze with RSI Divergence


ProScreener: Market Scanners & Detection

New Reply
Author
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Nicolas
8 years, 11 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 03/12/2017
Status: Active
Attachments: No files
Logo Logo
Loading...