Multiple timeframes RSI divergence

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #113734 quote
    Abz
    Participant
    Veteran

    hello , Big Thanks to Robertogozzi for converting 2 other screener if possible to convert this as well , i will try to use them in a manual strategy and if turns out good i will write down the rules and hopefully we can all benefit from it.

     

    //RSI Divergences Screener By Frank (Francesco)
    
    //Variables:
    //number of bars to calculare RSI value
    RsiPeriod = 10
    
    //Oversold Level
    RsiOverSold = 30
    
    //OverBought Level
    RsiOverBought = 70
    
    //Minimum distance from two consecutive RSI Highs or RSI Lows
    MinBarRange = 3
    
    MyRSI = rsi[RsiPeriod](Close)
    
    RsiMax = MyRSI < MyRSI[1] and MyRSI[1] > MyRSI[2] and MyRSI[1] > RsiOverBought
    RsiMin = MyRSI > MyRSI[1] and MyRSI[1] < MyRSI[2] and MyRSI[1] < RsiOverSold
    
    if RsiMax then
    RSIMax1 = MyRSI[1]
    High1 = High[1]
    for I = MinBarRange to  80
    if RsiMax[I] then
    RSIMax2 = MyRSI[I + 1]
    High2 = High[I + 1]
    break
    endif
    next
    endif
    
    CondRibassista = RsiMax and ((High1 > High2 and RSIMax1 < RSIMax2) or (High1 < High2 and RSIMax1 > RSIMax2))
    
    if RsiMin then
    RSIMin1 = MyRSI[1]
    Low1 = Low[1]
    for I = MinBarRange to  80
    if RSIMin[I] then
    RSIMin2 = MyRSI[I + 1]
    Low2 = Low[I + 1]
    break
    endif
    next
    endif
    
    CondRialzista = RsiMin and ((Low1 < Low2 and RSIMin1 > RSIMin2) or (Low1 > Low2 and RSIMin1 < RSIMin2))
    
    if CondRibassista then
    Result = 2
    endif
    
    if CondRialzista then
    Result = 1
    endif
    #113830 quote
    robertogozzi
    Moderator
    Master

    There you go:

    // 1 = ↑
    // 2 = ↓
    // 9 = no signal on that TF
    //
    // 4 = 4-hour TF
    // H = 1-hour TF
    // 1 = 15-minute TF
    // 5 = 5-minute TF
    //
    TIMEFRAME(default)
    //
    RsiPeriod     = 10
    RsiOverSold   = 30
    RsiOverBought = 70
    MinBarRange   = 3
    //
    TIMEFRAME(4 hour)
    XMyRSI = rsi[RsiPeriod](Close)
    XRsiMax = XMyRSI < XMyRSI[1] and XMyRSI[1] > XMyRSI[2] and XMyRSI[1] > RsiOverBought
    XRsiMin = XMyRSI > XMyRSI[1] and XMyRSI[1] < XMyRSI[2] and XMyRSI[1] < RsiOverSold
    //
    if XRsiMax then
    XRsiMax1 = XMyRSI[1]
    XHigh1 = High[1]
    for xI = MinBarRange to  80
    if XRsiMax[xI] then
    XRsiMax2 = XMyRSI[xI + 1]
    XHigh2 = High[xI + 1]
    break
    endif
    next
    endif
    XCondRibassista = XRsiMax and ((XHigh1 > XHigh2 and XRsiMax1 < XRsiMax2) or (XHigh1 < XHigh2 and XRsiMax1 > XRsiMax2))
    //
    if XRsiMin then
    XRsiMin1 = XMyRSI[1]
    XLow1 = Low[1]
    for xI = MinBarRange to  80
    if XRsiMin[xI] then
    XRsiMin2 = XMyRSI[xI + 1]
    XLow2 = Low[xI + 1]
    break
    endif
    next
    endif
    XCondRialzista = XRsiMin and ((XLow1 < XLow2 and XRsiMin1 > XRsiMin2) or (XLow1 > XLow2 and XRsiMin1 < XRsiMin2))
    XSignal= 9000
    IF XCondRialzista > 0 THEN
    XSignal = 1000
    ELSIF XCondRibassista > 0 THEN
    XSignal = 2000
    ENDIF
    //
    TIMEFRAME(1 hour)
    YMyRSI = rsi[RsiPeriod](Close)
    YRsiMaY = YMyRSI < YMyRSI[1] and YMyRSI[1] > YMyRSI[2] and YMyRSI[1] > RsiOverBought
    YRsiMin = YMyRSI > YMyRSI[1] and YMyRSI[1] < YMyRSI[2] and YMyRSI[1] < RsiOverSold
    //
    if YRsiMaY then
    YRsiMaY1 = YMyRSI[1]
    YHigh1 = High[1]
    for YI = MinBarRange to  80
    if YRsiMaY[YI] then
    YRsiMaY2 = YMyRSI[YI + 1]
    YHigh2 = High[YI + 1]
    break
    endif
    next
    endif
    YCondRibassista = YRsiMaY and ((YHigh1 > YHigh2 and YRsiMaY1 < YRsiMaY2) or (YHigh1 < YHigh2 and YRsiMaY1 > YRsiMaY2))
    //
    if YRsiMin then
    YRsiMin1 = YMyRSI[1]
    YLow1 = Low[1]
    for YI = MinBarRange to  80
    if YRsiMin[YI] then
    YRsiMin2 = YMyRSI[YI + 1]
    YLow2 = Low[YI + 1]
    break
    endif
    next
    endif
    YCondRialzista = YRsiMin and ((YLow1 < YLow2 and YRsiMin1 > YRsiMin2) or (YLow1 > YLow2 and YRsiMin1 < YRsiMin2))
    YSignal= 900
    IF YCondRialzista > 0 THEN
    YSignal = 100
    ELSIF YCondRibassista > 0 THEN
    YSignal = 200
    ENDIF
    //
    TIMEFRAME(15 minute)
    ZMyRSI = rsi[RsiPeriod](Close)
    ZRsiMaZ = ZMyRSI < ZMyRSI[1] and ZMyRSI[1] > ZMyRSI[2] and ZMyRSI[1] > RsiOverBought
    ZRsiMin = ZMyRSI > ZMyRSI[1] and ZMyRSI[1] < ZMyRSI[2] and ZMyRSI[1] < RsiOverSold
    //
    if ZRsiMaZ then
    ZRsiMaZ1 = ZMyRSI[1]
    ZHigh1 = High[1]
    for ZI = MinBarRange to  80
    if ZRsiMaZ[ZI] then
    ZRsiMaZ2 = ZMyRSI[ZI + 1]
    ZHigh2 = High[ZI + 1]
    break
    endif
    next
    endif
    ZCondRibassista = ZRsiMaZ and ((ZHigh1 > ZHigh2 and ZRsiMaZ1 < ZRsiMaZ2) or (ZHigh1 < ZHigh2 and ZRsiMaZ1 > ZRsiMaZ2))
    //
    if ZRsiMin then
    ZRsiMin1 = ZMyRSI[1]
    Zlow1 = low[1]
    for ZI = MinBarRange to  80
    if ZRsiMin[ZI] then
    ZRsiMin2 = ZMyRSI[ZI + 1]
    Zlow2 = low[ZI + 1]
    break
    endif
    next
    endif
    ZCondRialzista = ZRsiMin and ((Zlow1 < Zlow2 and ZRsiMin1 > ZRsiMin2) or (Zlow1 > Zlow2 and ZRsiMin1 < ZRsiMin2))
    ZSignal= 90
    IF ZCondRialzista THEN
    ZSignal = 10
    ELSIF ZCondRibassista THEN
    ZSignal = 20
    ENDIF
    //
    TIMEFRAME(5 minute)
    WMyRSI = rsi[RsiPeriod](Close)
    WRsiMaW = WMyRSI < WMyRSI[1] and WMyRSI[1] > WMyRSI[2] and WMyRSI[1] > RsiOverBought
    WRsiMin = WMyRSI > WMyRSI[1] and WMyRSI[1] < WMyRSI[2] and WMyRSI[1] < RsiOverSold
    //
    if WRsiMaW then
    WRsiMaW1 = WMyRSI[1]
    WHigh1 = High[1]
    for WI = MinBarRange to  80
    if WRsiMaW[WI] then
    WRsiMaW2 = WMyRSI[WI + 1]
    WHigh2 = High[WI + 1]
    break
    endif
    next
    endif
    WCondRibassista = WRsiMaW and ((WHigh1 > WHigh2 and WRsiMaW1 < WRsiMaW2) or (WHigh1 < WHigh2 and WRsiMaW1 > WRsiMaW2))
    //
    if WRsiMin then
    WRsiMin1 = WMyRSI[1]
    WLow1 = Low[1]
    for WI = MinBarRange to  80
    if WRsiMin[WI] then
    WRsiMin2 = WMyRSI[WI + 1]
    WLow2 = Low[WI + 1]
    break
    endif
    next
    endif
    WCondRialzista = WRsiMin and ((WLow1 < WLow2 and WRsiMin1 > WRsiMin2) or (WLow1 > WLow2 and WRsiMin1 < WRsiMin2))
    WSignal= 9
    IF WCondRialzista THEN
    WSignal = 1
    ELSIF WCondRibassista THEN
    WSignal = 2
    ENDIF
    //
    TIMEFRAME(default)
    Signal =  XSignal + YSignal + ZSignal + WSignal
    IF Signal = 9999 THEN
       Signal = 0
    ENDIF
    SCREENER[Signal](Signal AS "1=↑,2=↓/4H15")

    If you want to try to replace 9000, 900, 90 and 9 with 0 you will see what happens (leading 0’s are dropped, so 9929 becomes 20)  and if you like it more. If you don’t you can restore the original 9’s.

    I only tested it for syntax errors.

    Abz thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Multiple timeframes RSI divergence


ProScreener: Market Scanners & Detection

New Reply
Author
author-avatar
Abz @abbas_sadiq Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
6 years, 3 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 11/27/2019
Status: Active
Attachments: No files
Logo Logo
Loading...