Francesco

RSI classical and hidden Divergences Indicator

Category: Indicators By: Francesco Created: December 22, 2017, 4:32 PM
December 22, 2017, 4:32 PM
Indicators
33 Comments
RSI classical and hidden Divergences Indicator

After a long work, I finally developed a simple, but useful RSI Divergences Indicator -Hey! another one?-

Yes, another one! (but I hope it is better than the default ProRealTime RSI Divergences Indicator).

This indicator finds both Direct (or Regular) and Hidden (or Inverse) RSI Divergences.

When a divergence is found, an Arrow is drawn to the chart and a text is added to the Arrow to mark the type of Divergence: “dd” = Direct Divergence; “hd” = Hidden Divergence

Indicator parameters:

  • RsiPeriod: number of bars to calculate RSI value, Default=10
  • RsiOverSold: Oversold Level, Default=30
  • RsiOverBought: OverBought Level, Default=70
  • MinBarRange: minimum distance from two consecutive RSI Highs or RSI Lows, Default=3

Comparing my indicator with ProRealTime RSI Divergence Indicator (using same parameters values), i found that entry points are exactly the same, except for new arrows added by my indicator in case of hidden divergence. That’s why ProRealTime indicator shows only regular divergences.

You can play with parameters to change sensivity.

Briefly, an RSI Divergence screener will be follow.

Merry Christmas!

Ciao!

//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 = High[1]

 for I = MinBarRange to  80
  if RsiMax[I] then
   RSIMax2 = MyRSI[I + 1]
   High2 = High[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 = Low[1]

 for I = MinBarRange to  80
  if RSIMin[I] then
   RSIMin2 = MyRSI[I + 1]
   Low2 = Low[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

 

Download
Filename: RSI-Divergences-1.itf
Downloads: 2463
Francesco
Francesco Average
As an architect of digital worlds, my own description remains a mystery. Think of me as an undeclared variable, existing somewhere in the code.
Author’s Profile

Comments

Leduc71
3 months ago
#

La logique centrale est correcte : ce code détecte bien les divergences RSI classiques et cachées. Les syntaxes RSI[N](close), AverageTrueRange[N](close), les boucles et les instructions de dessin sont conformes à ProBuilder.

Ce qu’il détecte correctement

Aux sommets :

  • prix fait un plus haut, RSI un plus bas → divergence baissière classique ;
  • prix fait un plus bas, RSI un plus haut → divergence baissière cachée.

Aux creux :

  • prix fait un plus bas, RSI un plus haut → divergence haussière classique ;
  • prix fait un plus haut, RSI un plus bas → divergence haussière cachée.


Les limites importantes

1. Il ne renvoie actuellement aucune valeur numérique

La dernière ligne est simplement :

return

Si c’est bien l’intégralité du code, il dessine des flèches et du texte, mais ne renvoie pas +1, 0 ou –1. Or RETURN sert précisément à fournir la valeur exploitable de l’indicateur.

Pour les alertes, il faudrait notamment initialiser :

Signal = 0

puis mettre :

Signal = -1

dans les deux divergences baissières, et :

Signal = 1

dans les deux divergences haussières, puis terminer par :

RETURN Signal AS "Divergence RSI"

2. Il est très restrictif

Un sommet RSI n’est accepté que s’il est supérieur à RsiOverBought, et un creux seulement s’il est inférieur à RsiOverSold.

Ainsi, si tes seuils sont 70 et 20, les deux pivots doivent se former dans ces zones extrêmes. Cela élimine beaucoup de divergences valables, mais peut aussi réduire les signaux faibles. Le RSI et ses divergences ne nécessitent pas obligatoirement une présence au-dessus de 70 ou sous 30/20.

3. Il ne compare que le précédent pivot RSI trouvé

Dès que la boucle trouve le précédent sommet ou creux RSI, elle exécute BREAK, même si aucune divergence n’est constatée avec ce pivot. Elle ne recherche donc pas une divergence possible avec un pivot plus ancien.

Cela réduit les faux signaux, mais peut aussi manquer certaines divergences longues.

4. Il utilise les pivots du RSI, pas les véritables pivots du prix

Il prend simplement le High[1] ou le Low[1] correspondant au pivot RSI. Il ne vérifie pas explicitement que ce prix constitue lui aussi un sommet ou un creux structurel.

C’est acceptable, mais moins rigoureux qu’une détection exigeant simultanément :

  • un pivot RSI ;
  • un pivot du prix ;
  • un espacement minimal entre les deux points.

5. Les flèches sont dessinées une bougie après le pivot

Le pivot détecté se trouve sur la bougie [1], mais la flèche est dessinée sur :

barindex, High

Pour positionner la flèche exactement sur le pivot, il faudrait plutôt utiliser :

barindex - 1, High[1]

et, pour une divergence haussière :

barindex - 1, Low[1]

Les fonctions de dessin utilisent bien BarIndex pour la position horizontale.

Verdict

Le calcul des quatre types de divergences est juste, mais ce code :

  • filtre fortement les signaux par les zones de surachat/survente ;
  • ne considère que le pivot RSI précédent ;
  • peut manquer des divergences plus anciennes ;
  • ne fournit pas encore de signal numérique utilisable pour tes alertes, si la ligne RETURN est réellement vide.

Et en temps réel, la divergence peut encore apparaître puis disparaître pendant la bougie de confirmation ; à la clôture, elle devient beaucoup plus stable.

Metodi97
3 years ago
#

This indicator is great but can someone create strategy based on the same indicator it will be great. Thank you in advance and have a good and profitable week :)

Alai-n
4 years ago
#

Ciao Francesco, sei ancora in giro?

SpreadBetMH
5 years ago
#

Hi there, I have V11.1. I get the Indicator but no Arrows on the price. Kind Regards Michael

Geoffrey Toplis
6 years ago
#

Hi Francesco, Great Indicator and thanks for sharing. How exactly does the MinRangeBar setting work? It sounds self explanatory but if i change from min 5 to min 3 some signals disappear - I would've thought that more would appear with the min bar range down. Is it based on the price or RSI? Regards, Geoff

sisco771
6 years ago
#

Bonjour. je viens de telecharger cet indicateur .Malheureusement il ne fonctionne pas ou plus !? J'ai essayer deux fois sans succès . il s'affiche correctement mais aucune courbe ne s'affiche !! Quelqu'un aurait-il rencontrer le même problème que moi?. merci d'avance pour vos retours.

llsegard
7 years ago
#

bonjour, merci pour cet indicateur très utile - Pouvez expliquer pourquoi l'indicateur apparaît dessous/dessus le chandelier lorsque la divergence est détectée sur les ut intraday alors qu'il apparaît le lendemain en ut journalière. j'ai testé les différents paramètres et je n'arrive pas à résoudre ce problème. merci pour vos retours. Ludovic

shmilg
7 years ago
#

Nice

Denis
7 years ago
#

Hello Francesco, I have the same problem as Bard, a blank indicator without any return value. Coul you help me please ? Many thanks

Adil
8 years ago
#

How to install in META 4 ?

Nicolas
8 years ago
#

Our website is about programming for ProRealTime trading platform and not about Metatrader4! https://trading.prorealtime.com/en/

robdav
8 years ago
#

Try this link, it actually works. https://drive.google.com/file/d/1-EZBYlTi8qWOYT4_ZxgTlE0aUcnfKF6t/view?usp=sharing

robdav
8 years ago
#

https://drive.google.com/file/d/1-AQ4AS7LGV6hDJGUmKELNkHb_HZwuJ1_/view?usp=sharing

robdav
8 years ago
#

Hi Francesco I appreciate you uploaded this a long time ago but it is a useful indicator if you can't spot the divergences manually. Interestingly I've compared it on IG Index spreadbet chart data and ProRealTime real market data and it highlights more interesting divergences on the real data which I guess is not a surprise. I've uploaded an image that compares a 5 min chart and you can see the differences. Thought you or someone else might be interested. Cheers Rob

Bard
8 years ago
#

Hi, When I download this it says RSI Divergences 1 itf, not 2? There are no Return values and it'a a blank indicator? Any ideas anyone?

olpey
8 years ago
#

Hello Francesco, Is there any parameters that you recommend for lower or higher TF please Thank You Grazie Mile

remembers
8 years ago
#

Salve ho notato che questo indicatore non mi funziona importandolo correttamente. Idee?

fabioerliam
9 years ago
#

P.s. ho provato a togliere le divergenze nascoste (hd) dall'indicatore, ma nonostante inserisca gli stessi parametri, non mi da gli stessi segnali che mi da invece l'indicatore di divergenze rsi quello standard della piattaforma...

fabioerliam
9 years ago
#

Ciao Francesco! Ti disturbo ancora per chiederti se conosci o se eventualmente pensi si possa generare un comando di buy o sell all'incrocio di 2 MM, ma dopo che si verifichi una divergenza sul tuo indicatore rsi...magari se ci fosse la possibilità anche di stabilire dopo quante barre dalla divergenza il segnale possa definirsi valido...per esempio mi scatta la divergenza e se entro max 5 barre si incrociano le mm ok...se no non prendere l'ordine....la vedo dura:) Grazie caro

fabioerliam
9 years ago
#

Grazie! Buona giornata

fabioerliam
9 years ago
#

Ciao Francesco! Grazie per l'indicatore che da tanto stavo cercando inutilmente di provare a creare! Ho un paio di domande da farti... L'ATR che hai inserito all'inizio serve a? :) non credo abbia a che fare con lo strumento...penso che serva a disegnare qualcosa sul grafico...esatto? Cosa intendi con shiftext? Valore 3? Sono il numero di barre che considera per verificare se c'è o no la divergenza? Pensavo che quell'istruzione fosse data dal minbarrange...... Confusion....;( Mi dai una mano?:) Grazie mille di tutto!!!

Francesco
9 years ago
#

ShiftText serve semplicemente a far sì che il testo e la freccia non si sovrapoongano. Come avevi capito da solo, l'ATR serve solo a calcolare l'ordinata del punto sul quale piazzare la freccia sul grafico.

brendab180
9 years ago
#

I am new to prorealtime and when I add this is wants to put it in a lower frame how do I get it to show up on my chart frame. Thanks for your help

Francesco
9 years ago
#

1- Download attached file rsi-divergences-2.itf 2- Here is how to import indicator into your platform: https://www.prorealcode.com/import-export-prorealtime-code-platform/ 3- Here is how to add indicator to your chart https://www.prorealtime.com/en/help-manual/technical-analysis-indicators Here is how to show it on your char

Francesco
9 years ago
#

@Inertia: yes, you have to replace Drawarrow and Drawtext with Buy or Sell orders.

Inertia
9 years ago
#

Very nice Franceso. Like it. Q: to turn your indicator into a strategy, shall I just replace lines Drawarrows and draw text with "Buy 1 contract at market" ? Sorry still learning :( cause I've tried of course and it doesn't work...Do not laught ;)

LuisMi
9 years ago
#

J'ai trouvé pour rajouter les variables... thanx for indicator

LuisMi
9 years ago
#

Hello merci pour l'indicateur j'ai un message d'erreur Veuillez définir la variable suivante : rsipériod Veuillez définir la variable suivante :rsioverbought Veuillez définir la variable suivante :rsioversold Veuillez définir la variable suivante : minbarrange quel sont ces données et ou dois je les mettre? merci par avance

Francesco
9 years ago
#

Ho provato ad inserire i segmenti per evidenziare le divergenze, ma al momento non sono riuscito ad individuare correttamente i punti, per cui i segmenti stessi mi venivano disegnati nei punti e con le inclinazioni sbagliate. Cmq, per disegnarli devi individuare i punti (x1, y1) e (x2, y2) che sono le coordinate dei due punti estremi del segmento. x1 dovrebbe essere la candela (il barindex) del minimo (o massimo) più vecchio e y1 il relativo valore di RSI. Allo stesso modo, x2 è la candela del secondo minimo (o massimo) più recente e y2 il relativo valore di RSI. In effetti i rispettivi valori di RSI (cioè y1 e y2) possono essere letti dalle variabili RSIMax1 e RSIMax2 (nel caso dei massimi); RSIMIn1 RSIMin2 nela caso dei minimi. x1 e x2 andrebbero letti dalla variabile "I" che rappresenta il barindex man mano che il ciclo for --> next viene scorso. Ci ho provato, ma le riche mi venivano disegnate tutte storte. Ci devo lavorare.

Alai-n
9 years ago
#

Ciao Francesco, oltre alle istruzioni grafiche (DRAWARROWUP e DOWN / DRAWTEXT) che hai inserito nel codice avrei voluto inserire DRAWSEGMENT che funziona nel tempo, purché non venga rilevata un'altra divergenza !!! Hai qualche idea su come fare questo ???

ProRealCode ProRealCode
Loading...