Divergencias

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #250787 quote
    Principiante
    Participant
    New

    Intento crear un ProScreeener para detectar divergencias con el RSI 14 y el precio, he encontrado en ProRealCode el siguiente codigo pero me da error.

    ¿Hay alguna posibilidad de disponer de un código que buque divergencias alcistas en todos los marcos de tiempo? y que solo filtre valores que negocien en dia mas de 1.000.000 de titulos.

    Así como disponer de un código para buscar divergencias bajista en todos los marcos temporales y que solo filtre valores que negocien en dia mas de 1.000.000 de titulos.

    Gracias

    pego el código, el error lo da en la línea 47 :

    //-----------------------------------------------//
    //PRC_RSI Divergence
    //version = 0
    //05.05.2025
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //-----------------------------------------------//
    // inputs
    //-----------------------------------------------//
    src=(open+high+low+close)/4
    x=5
    z=25
    revpct=0.01
    ialert=25
    rsiprd=14
    ob=70
    os=30
    //-----------------------------------------------//
    // RSI calculation
    //-----------------------------------------------//
    rv=rsi[rsiprd](src)
    //-----------------------------------------------//
    // Bullish Divergence
    //-----------------------------------------------//
    //--- Define lower low in price
    llvx=lowest[x](src)
    llvz=lowest[z](src)
    srcLL=src>llvx*(1+revpct) and llvx<llvz[x]
    //--- Define higher low in RSI
    llvrsix=lowest[x](rv)
    llvrsiz=lowest[z](rv)
    rsiHL=rv>llvrsix and llvrsix>llvrsiz[x] and llvrsix<os
    
    bullishDiv=srcLL and rsiHL
    
    if bullishDiv then
       count=1
    else
       count=1+count
    endif
    
    if count<ialert then
       bullishDivAlert=10+50
    else
       bullishDivAlert=50
    endif
    colorbetween(bullishDivAlert,50,"green",100)
    //-----------------------------------------------//
    // Bearish Divergence
    //-----------------------------------------------//
    //--- define higher high in price
    hhvx=highest[x](src)
    hhvz=highest[z](src)
    srcHH=src<hhvx*(1-revpct) and hhvx>hhvz[x]
    
    //--- define lower high in rsi
    hhvrsix=highest[x](rv)
    hhvrsiz=highest[z](rv)
    rsiLH=rv<hhvrsix and hhvrsix<hhvrsiz[x] and hhvrsix>ob
    
    bearishDiv=srcHH and rsiLH
    if bearishDiv then
       countbear=1
    else
       countbear=1+countbear
    endif
    
    if countbear<ialert then
       bearishDivAlert=50-10
    else
       bearishDivAlert=50
    endif
    colorbetween(bearishDivAlert,50,"red",100)
    //-----------------------------------------------//
    if bullishdiv then
       red=0
       green=255
       blue=0
    elsif bearishdiv then
       red=255
       green=0
       blue=0
    else
       red=0
       green=0
       blue=255
    endif
    //-----------------------------------------------//
    return rv as "RSI" coloured(red,green,blue)style(line,2), bullishDivAlert coloured("green"), bearishDivAlert coloured("red"), ob style(dottedline), os style(dottedline), 50 as "midline"
    #250788 quote
    JS
    Participant
    Master

    Hello,

    The code you are using is designed for an indicator…

    To convert it into a screener, you must remove all graphic elements and alert functions, and replace the RETURNwith SCREENER[…]

    Try this…

    //-----------------------------------------------//
    //RSI Divergence Screener
    //Iván González @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    //-----------------------------------------------//
    // inputs
    //-----------------------------------------------//
    src=(open+high+low+close)/4
    x=5
    z=25
    revpct=0.01
    //ialert=25
    rsiprd=14
    ob=70
    os=30
    //-----------------------------------------------//
    // RSI calculation
    //-----------------------------------------------//
    rv=rsi[rsiprd](src)
    //-----------------------------------------------//
    // Bullish Divergence
    //-----------------------------------------------//
    //--- Define lower low in price
    llvx=lowest[x](src)
    llvz=lowest[z](src)
    srcLL=src>llvx*(1+revpct) and llvx<llvz[x]
    //--- Define higher low in RSI
    llvrsix=lowest[x](rv)
    llvrsiz=lowest[z](rv)
    rsiHL=rv>llvrsix and llvrsix>llvrsiz[x] and llvrsix<os
    
    bullishDiv=srcLL and rsiHL
    
    if bullishDiv then
    count=1
    else
    count=1+count
    endif
    
    //-----------------------------------------------//
    // Bearish Divergence
    //-----------------------------------------------//
    //--- define higher high in price
    hhvx=highest[x](src)
    hhvz=highest[z](src)
    srcHH=src<hhvx*(1-revpct) and hhvx>hhvz[x]
    
    //--- define lower high in rsi
    hhvrsix=highest[x](rv)
    hhvrsiz=highest[z](rv)
    rsiLH=rv<hhvrsix and hhvrsix<hhvrsiz[x] and hhvrsix>ob
    
    bearishDiv=srcHH and rsiLH
    if bearishDiv then
    countbear=1
    else
    countbear=1+countbear
    endif
    
    Screener[(bullishdiv or bearishdiv) and Volume>1000000]
    
    robertogozzi and Iván González thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Divergencias


ProScreener: Buscadores de Mercado y Rastreo

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by JS
1 year ago.

Topic Details
Forum: ProScreener: Buscadores de Mercado y Rastreo
Language: Spanish
Started: 09/13/2025
Status: Active
Attachments: No files
Logo Logo
Loading...