Tutte le divergenze RSI

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #227499 quote
    PaFM
    Participant
    New

    Salve,

    sto cercando un modo per individuale automaticamente tutte le divergenze (dirette e nascoste) presenti tra prezzo ed RSI a 12 periodi, ho navigato nella libreria ed ho importato il codice qui sotto, ma funziona solo per le divergenze dirette (disegnando dei segmenti colorati direttamente sul RSI), ma a seconda di come viene settato il periodo (N=numero di barre) individua (alternativamente) solo quelle di breve termine o solo quelle più “lunghe”, mentre io vorrei che venissero individuate tutte; ed inoltre non trova le divergenze nascoste.

    ///N=    ///N is the number of bars to look back for a divergence.
    
    myrsi = RSI[12](close)
    
    
    IF (myrsi[1]>myrsi AND myrsi[1]>myrsi[2]) THEN
    newmaxrsi=myrsi[1]
    oldmaxrsi=highest[N](myrsi)
    newmaxprice=close[1]
    oldmaxprice=Highest[N](close)
    IF(newmaxrsi<oldmaxrsi AND newmaxprice>oldmaxprice[1]) THEN
    
    for j=1 to N
    if myrsi[j]=oldmaxrsi then
    zzr=j
    drawsegment (barindex[1], myrsi[1], barindex[zzr], myrsi[zzr])coloured(155,0,0)style(line,2)
    DRAWPOINT(barindex[1], myrsi[1],1)coloured(155,0,0,0)BORDERCOLOR(155,0,0)
    DRAWPOINT(barindex[zzr], myrsi[zzr],1)coloured(155,0,0,0)BORDERCOLOR(155,0,0)
    endif
    next
    endif
    endif
    
    
    IF (myrsi[1]<myrsi AND myrsi[1]<myrsi[2]) THEN
    newminrsi=myrsi[1]
    oldminrsi=lowest[N](myrsi)
    newminprice=close[1]
    oldminprice=lowest[N](close)
    IF(newminrsi>oldminrsi AND newminprice<oldminprice[1]) THEN
    for j2=1 to N
    if myrsi[j2]=oldminrsi then
    zzr2=j2
    drawsegment (barindex[1], myrsi[1], barindex[zzr2], myrsi[zzr2])coloured(0,155,0)style(line,2)
    DRAWPOINT(barindex[1], myrsi[1],1)coloured(0,155,0,0)BORDERCOLOR(0,155,0)
    DRAWPOINT(barindex[zzr2], myrsi[zzr2],1)coloured(0,155,0,0)BORDERCOLOR(0,155,0)
    endif
    next
    endif
    endif
    
    
    return myrsi as "RSI"

    Andando avanti nella ricerca ho trovato questo secondo codice, che ho personalizzato, che dovrebbe individuare entrambi i tipi di divergenze con delle frecce sul grafico in alto, ma non esce assolutamente nulla.

    //RSI Divergences By Frank (Francesco)
    
    //Description: the indicator draws arrows on chart as entry points when a direct or an hidden RSI divergence is found.
    //When a DIRECT divergence is found, "dd" (direct divergence) text is added to chart over (Sell signal) or under (Buy signal) the arrow
    
    //When an HIDDEN or INVERSE divergence is found, "hd" (hidden divergence) text is added to chart over (Sell signal) or under (Buy signal) the arrow
    
    //Variables:
    //RsiPeriod: number of bars to calculare RSI value
    //RsiOverSold: Oversold Level
    //RsiOverBought: OverBought Level
    //MinBarRange: minimum distance from two consecutive RSI Highs or RSI Lows
    
    Rge = averagetruerange[10](close)
    MyRSI = rsi[RsiPeriod](Close)
    
    ONCE ShiftText = 3
    
    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 = Close[1]
    
    for I = MinBarRange to  40
    if RsiMax[I] then
    RSIMax2 = MyRSI[I + 1]
    High2 = Close[I + 1]
    If High1 > High2 and RSIMax1 < RSIMax2 then
    DRAWARROWDOWN(barindex, High + Rge / ShiftText)coloured(255,192,203,255)
    DRAWTEXT("dd", barindex, High + Rge / ShiftText / 0.3,SansSerif,Italic,10)coloured(0,0,255,255)
    elsif High1 < High2 and RSIMax1 > RSIMax2 then
    DRAWARROWDOWN(barindex, High + Rge / ShiftText)coloured(255,192,203,255)
    DRAWTEXT("hd", barindex, High + Rge / ShiftText / 0.2,SansSerif,Italic,10)coloured(0,0,255,255)
    endif
    break
    endif
    next
    endif
    
    if RsiMin then
    RSIMin1 = MyRSI[1]
    Low1 = Close[1]
    
    for I = MinBarRange to  80
    if RSIMin[I] then
    RSIMin2 = MyRSI[I + 1]
    Low2 = Close[I + 1]
    If Low1 < Low2 and RSIMin1 > RSIMin2 then
    DRAWARROWUP(barindex, lOW - Rge / ShiftText)coloured(0,0,255,255)
    DRAWTEXT("dd", barindex, lOW - Rge / ShiftText / 0.3,SansSerif,Italic,10)coloured(0,0,255,255)
    elsif Low1 > Low2 and RSIMin1 < RSIMin2 then
    DRAWARROWUP(barindex, lOW - Rge / ShiftText)coloured(0,0,255,255)
    DRAWTEXT("hd", barindex, lOW - Rge / ShiftText / 0.2,SansSerif,Italic,10)coloured(0,0,255,255)
    endif
    break
    endif
    next
    endif
    
    return

    Grazie in anticipo per il prezioso aiuto
    Cordialmente
    P

    #227529 quote
    jacquesgermain
    Participant
    Senior

    Ciao, anche questo fornisce le discrepanze nascoste:

    https://www.prorealcode.com/prorealtime-indicators/divergences-and-hidden-divergences-toolbox/

    il N=numero di barre è configurabile dal pannello di configurazione

    #227699 quote
    PaFM
    Participant
    New

    Grazie del suggerimento Jacques, sei molto cortese; in realtà ho passato diverse ore a provare tutte le alternative – per le divergenze – che sono presenti nella library, ma purtroppo non ne trovo nemmeno una che faccia al mio caso, o perché non funziona del tutto o perché non è personalizzabile come desidero o perché ne trova solo alcune oppure addirittura ne trova troppe … non c’è niente di ben fatto in realtà su questo argomento, peccato perché sarebbe davvero utile ….. se qualche anima pia mi vuole aiutare è il benvenuto …..

    Cordialmente
    P

    PS Ho provato ad usare anche l’indicatore di default su PRT ma è molto limitato, non è personalizzabile, graficamente è orribile e non trova quelle nascoste (inverse) …. non funziona per niente come vorrei …

    #227948 quote
    larouedegann
    Participant
    Master
    MiRSI  = RSI[14](close)
    Offset = MiRSI * 0.1
    IF (BarIndex > 10+1+N) THEN
    ///divergencia bajista
    IF (miRSI[1]>miRSI AND miRSI[1]>miRSI[2]) THEN
    extremum2=miRSI[1]
    extremum1=highest[N](miRSI)
    preciomax2=close[1]
    preciomax=Highest[N](close)
    IF(extremum2<extremum1 AND preciomax2>preciomax[1]) THEN
    for i=1 to N
    if miRSI[i]=extremum1 then
    zz=i
    drawsegment (barindex[1], miRSI[1]+Offset, barindex[zz], miRSI[zz]+Offset) coloured("RED")STYLE(line,4)
    endif
    next
    endif
    endif
    ///divergencia alcista
    IF (miRSI[1]<miRSI AND miRSI[1]<miRSI[2]) THEN
    extremum22=miRSI[1]
    extremum11=lowest[N](miRSI)
    preciomin2=close[1]
    preciomin=lowest[N](close)
    IF(extremum22>extremum11 AND preciomin2<preciomin[1]) THEN
    for i2=1 to N
    if miRSI[i2]=extremum11[1] then
    zz2=i2
    drawsegment(barindex[1], miRSI[1]-Offset, barindex[zz2], miRSI[zz2]-Offset) coloured("DARKGREEN")STYLE(line,4)
    endif
    next
    ENDIF
    ENDIF
    endif
    return miRSI as "RSI", 50 as "50"
    PaFM thanked this post
    #227949 quote
    larouedegann
    Participant
    Master

    N= 40

    #227981 quote
    jacquesgermain
    Participant
    Senior

    Ciao nel file allegato, indicatore simile ma migliorato con divergenze nascoste in aggiunta

    PaFM thanked this post
    RSI-Divergences-indicator.itf
    #228021 quote
    PaFM
    Participant
    New

    Sembra che funzioni bene anche con le nascoste, grazie tante!
    Tres bien,  merci beaucoup!

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

Tutte le divergenze RSI


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
author-avatar
PaFM @pafm Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by PaFM
2 years ago.

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 02/07/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...