gabri

RSI Divergences finder

Category: Indicators By: gabri Created: April 19, 2017, 2:45 PM
April 19, 2017, 2:45 PM
Indicators
40 Comments
RSI Divergences finder

This indicator finds the divergences between price and RSI and draw a segment (on price on RSI or both) at the highest value between the two peaks (for bullish divergencies) or at the lowest value reached between the two bottoms (for bearish divergencies). I use this levels as entry for long/short positions. Only when the price close above or under this levels I have an entry signal. On the picture is hard to see the segments because PRT doesn’t allow to change the tickness and the style.

Blue skies

//Variables
a=rsi[14](close)
once RefCloseDownOld=0
once RefRSIDownOld=0
once RefCloseUpOld=0
once RefRSIUpOld=0
once BarBullOld=0
once BarBearOld=0

//Conditions to identify max and min
c1=a[4]>a[2] and a[3]>a[2] and a[1]>a[2] and a>a[2]
c2=a[4]<a[2] and a[3]<a[2] and a[1]<a[2] and a<a[2]

//finding the double bottom
if c1 then
 RefCloseDownNew=close[2]
 RefRSIDownNew=a[2]
 BarBullNew=barindex[2]
endif
if RefCloseDownNew<RefCloseDownOld and RefRSIDownNew>RefRSIDownOld then
 //double slash next line if you don't needed the mark on a different window
 bulldiv=1
 //entry price for long on price window // double slash next line if not needed
 DRAWSEGMENT(BarBullNew, highest[(BarBullnew-BarBullOld)](close[1]), BarBullNew+10, highest[(BarBullnew-BarBullOld)](close[1]))
 //entry price for long on RSI window // double slash next line if not needed
 DRAWSEGMENT(BarBullNew, highest[(BarBullnew- BarBullOld)](a[1]), BarBullNew+10, highest[(BarBullnew-BarBullOld)](a[1]))
else
 bulldiv=0
endif

//Finding the double top
if c2 then
 RefCloseUpNew=close[2]
 RefRSIUpNew=a[2]
 BarBearNew=barindex[2]
endif
if RefCloseUpNew>RefCloseUpOld and RefRSIUPNew<RefRSIUpOld then
 //double slash next line if you don't needed the mark on a different window
beardiv=-1
 //entry price for short on price window // double slash next line if not needed
 DRAWSEGMENT(BarBearNew, LOWEST[(BarBearnew-BarBearOld)](close[1]), BarBearNew+10,  LOWEST[(BarBearnew-BarBearOld)](close[1]))
 //entry price for short on RSI window // double slash next line if not needed
 DRAWSEGMENT(BarBearNew, LOWEST[(BarBearnew-BarBearOld)](a[1]), BarBearNew+10, LOWEST[(BarBearnew-BarBearOld)](a[1]))
else
 beardiv=0
endif

//drawing
RefCloseDownOld=RefCloseDownNew
RefRSIDownOld=RefRSIDownNew
RefCloseUpOld=RefCloseUpNew
RefRSIUpOld=RefRSIUpNew
BarBullOld=BarBullNew
BarBearOld=BarBearNew

return bulldiv, beardiv

Download
Filename: Mio-divergenza-RSI.itf
Downloads: 665
gabri
gabri Master
Developer by day, aspiring writer by night. Still compiling my bio... Error 404: presentation not found.
Author’s Profile

Comments

seb234
6 years ago
#

Salut Mika, j'ai la version V11.1, la formule fonctionne. Mais il est préférable, dixit Nicolas, d'importer la formule (mio-divergenza-rsi.itf) plutôt que de faire un copier coller

Mika83
6 years ago
#

Bonjour, J'ai des soucis de lecture de syntaxe avec la variable "drawsegment" sur la version PRT 2021 gratuite. Et par ailleurs sur beaucoup d'autre code de divergence RSI, car beaucoup utilise cette variable. Je cherche un screener de divergences RSI et je n'ai pas le niveau pour régler ce probleme... Pourriez-vous m'aider, merci d'avance.

Djo
Djo
6 years ago
#

Not working on V11. The RSI doesn't appear on the chart.

Cedlam
7 years ago
#

Bonjour à tous, J'ai essayé de mettre de la couleur et les segments restent blanc. Avez-vous une solution ? D'avance merci.

Kris75
8 years ago
#

Based on this wonderful job I would like to propose this little change in the code that allows to make the divergent highs and lows more conspicuous on the RSI chart; (sorry to post the code like this, but the insert does not seem to work here ) Best //Variables a=rsi[14](close) once RefCloseDownOld=0 once RefRSIDownOld=0 once RefCloseUpOld=0 once RefRSIUpOld=0 once BarBullOld=0 once BarBearOld=0 //Conditions to identify max and min c1=a[4]>a[2] and a[3]>a[2] and a[1]>a[2] and a>a[2] // bottom c2=a[4]<a[2] and a[3]<a[2] and a[1]<a[2] and a<a[2] // top //finding the double bottom if c1 then RefCloseDownNew=close[2] RefRSIDownNew=a[2] BarBullNew=barindex[2] endif if RefCloseDownNewRefRSIDownOld then //double slash next line if you don't needed the mark on a different window bulldiv=a*0.9 //entry price for long on price window // double slash next line if not needed //DRAWSEGMENT(BarBullOld, RefCloseDownOld - 2, BarBullNew, RefCloseDownNew - 2)coloured(255,0,0) //entry price for long on RSI window // double slash next line if not needed DRAWSEGMENT(BarBullOld, RefRSIDownOld - 2, BarBullNew, RefRSIDownNew - 2)coloured(255,0,0) else bulldiv=0 endif //Finding the double top if c2 then RefCloseUpNew=close[2] RefRSIUpNew=a[2] BarBearNew=barindex[2] endif if RefCloseUpNew>RefCloseUpOld and RefRSIUPNew<RefRSIUpOld then //double slash next line if you don't needed the mark on a different window beardiv=a*0.9 //entry price for short on price window // double slash next line if not needed //DRAWSEGMENT(BarBearOld, RefCloseUpOld - 2, BarBearNew, RefCloseUpNew - 2)coloured(255,0,0) //entry price for short on RSI window // double slash next line if not needed DRAWSEGMENT(BarBearOld, RefRSIUpOld + 2, BarBearNew, RefRSIUpNew + 2)coloured(255,0,0) else beardiv=0 endif RefCloseDownOld=RefCloseDownNew RefRSIDownOld=RefRSIDownNew RefCloseUpOld=RefCloseUpNew RefRSIUpOld=RefRSIUpNew BarBullOld=BarBullNew BarBearOld=BarBearNew //grafica return bulldiv coloured (0,255,0) style (histogram,1), beardiv coloured (255,0,0) style (histogram,1)

gabri
8 years ago
#

Kris, you are always too nice!!

Kris75
8 years ago
#

Fantastic job ; hugely useful ; Thanks Gabri ;-)

Mert
9 years ago
#

Thanks, Gabri.

JohnScher
9 years ago
#

Only the indicators change in line 2? That's all? I'll try it! I'll answer when it's done. Thank´s so lot.

gabri
9 years ago
#

Thanks John. I guess you can change line 2 to use some other indicators. I use only RSI and RMI and so I tailored this code around it. to use MACD you can change line 2 to read a=MACDline[12,26,9](close) (or MACD[12,26,9](close)).

JohnScher
9 years ago
#

Great work, I like very much! Can you encode this for other indicators that also provide strong divergence signals? Maybe MACD, stochastics, momentum. I have in mind to create a divergence strategy, let's say 5 divergences, and if 3 out of 5 agree the trade is started. See Screenshort attached, the 1x you can see Bearic divergences of CCI, MACD, RSI in the same candle Bullish divergences of CCI, MACD, RSI in the same candle Accordingly, the share price "follows" the divergences... Can you program that? Translated with www.DeepL.com/Translator

gabri
9 years ago
#

Mert, instead of the following line: if RefCloseDownNewRefRSIDownOld then just write if RefCloseDownNewRefRSIDownOld and aRefCloseUpOld and RefRSIUPNewRefCloseUpOld and RefRSIUPNew70 then it should help.

Mert
9 years ago
#

Hello Gabri, I looked at your divergence finder and it looks great. Is there a possible that you write some extra code so that the divergence is only found in oversold and overbought levels? That would be highly appreciated. Thanks in advance and with warmest regards,

Andy
10 years ago
#

ok thanks!

gabri
10 years ago
#

Ok, I believe your version of PRT doesn't support the command drawsegment. You should check with the helpdesk.

Andy
10 years ago
#

22 DRAWSEGMENT(BarBullNew, highest[(BarBullnew-BarBullOld)](close), BarBullNew+10, highest[(BarBullnew-BarBullOld)](close))
//entry price for long on RSI window // double slash next line if not needed
24 DRAWSEGMENT(BarBullNew, highest[(BarBullnew-BarBullOld)](a), BarBullNew+10, highest[(BarBullnew-BarBullOld)](a))

There is a warning signal on both..

 

gabri
10 years ago
#

In my code there is no character 12 on line 22!! can you tell me which is your line 22?

Andy
10 years ago
#

ok tried.. it says:

Errore nell'indicatore: Mio - divergenza RSI
Errore di sintassi: Linea 22, carattere 12
Uno dei seguenti caratteri sarebbe più appropriato di "(":
- ","
- "="

Andy
10 years ago
#

wow.. probably i did something wrong.. let me try :D

gabri
10 years ago
#

Andy, that was another code I made. You should either import the mio-divergenza-rsi.itf file that you find in the attachments or copy the code above and make a new indicator on your PRT (you can name it the way you want). After these steps are done click on the wrench symbol, then choose “Add indicator” and click on the indicator you just made (or imported)

Andy
10 years ago
#

i have only "Mio-rsi sui prezzi" as indicatore available, is it this one?

gabri
10 years ago
#

Ok, try this. On the price window (or on the RSI window) click on the wrench symbol, then choose "Add indicator" and click on the indicator "mio-divergenza-rsi". Does it work like this?

gabri
10 years ago
#

I am not sure about the problem. If you have the 10.3 version of PRT you should be able to see it. Sorry!!

Andy
10 years ago
#

no i dont see any lines..

I have a mac and my version is Java 1.0

gabri
10 years ago
#

It should say your version when you start the program. Do you see any lines on the RSI graph?

Andy
10 years ago
#

i dont know Gabri.. how can i check?

gabri
10 years ago
#

Andy,

could it be that the PRT version you are using doesn't support the function DRAWSEGMENT?

Andy
10 years ago
#

before trying i noticed that it says there is error on line 24 and 26

Andy
10 years ago
#

wow what a speed reply.. i'll try and let you know, thanks

ProRealCode ProRealCode
Loading...