jacquesgermain

MACD RSI MFI Divergences on price and on indicators

Category: Indicators By: jacquesgermain Created: August 22, 2023, 2:43 PM
August 22, 2023, 2:43 PM
Indicators
4 Comments
MACD RSI MFI Divergences on price and on indicators

This is an indicator that shows divergences on price and MACD and RSI and MFI at the same time.

you need to put 1 indicator on the price chart and another as a new indicator.

Divergences are drawn automatically and it does not repaint.

Thanks to José CALLAO

N=40///N is the number of bars to look back for a divergence. Normal values are 20-40. Must be the same in both indicators
//using any other indicator is as easy as changing the values

miMACD = exponentialAverage[12](close)-exponentialAverage[26](close)
miRSI = RSI[14](close)
mimfi = MoneyFlowIndex[14]

IF (BarIndex > 10+1+N) THEN
IF (miMACD[1]>miMACD AND miMACD[1]>miMACD[2]) THEN
extremum2=miMACD[1]
extremum1=highest[N](miMACD)
preciomax2=close[1]
preciomax=Highest[N](close)
IF(extremum2<extremum1 AND preciomax2>preciomax[1]) THEN
for i=1 to N
if close[i]=preciomax[1] then
zzm=i
if divmacd then
drawsegment (barindex[1], close[1], barindex[zzm],close[zzm]) coloured(0,0,155)style(dottedline,2)
endif
endif
next
endif
endif
IF (miMACD[1]<miMACD AND miMACD[1]<miMACD[2]) THEN
extremum22=miMACD[1]
extremum11=lowest[N](miMACD)
preciomin2=close[1]
preciomin=lowest[N](close)
IF(extremum22>extremum11 AND preciomin2<preciomin[1]) THEN
for i2=1 to N
if close[i2]=preciomin[1] then
zzm2=i2
if divmacd then
drawsegment(barindex[1], close[1], barindex[zzm2], close[zzm2]) coloured(0,0,155)style(line,2)
endif
endif
next
endif
endif
IF (miRSI[1]>miRSI AND miRSI[1]>miRSI[2]) THEN
extremumr2=miRSI[1]
extremumr1=highest[N](miRSI)
preciomaxr2=close[1]
preciomaxr=Highest[N](close)
IF(extremumr2<extremumr1 AND preciomaxr2>preciomaxr[1]) THEN
for j=1 to N
if close[j]=preciomaxr[1] then
zzr=j
if divrsi then
drawsegment (barindex[1], close[1], barindex[zzr], close[zzr]) coloured(0,155,0)style(dottedline,2)
endif
endif
next
endif
endif
IF (miRSI[1]<miRSI AND miRSI[1]<miRSI[2]) THEN
extremumr22=miRSI[1]
extremumr11=lowest[N](miRSI)
preciominr2=close[1]
preciominr=lowest[N](close)
IF(extremumr22>extremumr11 AND preciominr2<preciominr[1]) THEN
for j2=1 to N
if close[j2]=preciominr[1] then
zzr2=j2
if divrsi then
drawsegment(barindex[1], close[1], barindex[zzr2], close[zzr2]) coloured(0,155,0)style(line,2)
endif
endif
next
endif
endif

IF (mimfi[1]>mimfi AND mimfi[1]>mimfi[2]) THEN
extremummfi2=mimfi[1]
extremummfi1=highest[N](mimfi)
preciomaxmfi2=close[1]
preciomaxmfi=Highest[N](close)
IF(extremummfi2<extremummfi1 AND preciomaxmfi2>preciomaxmfi[1]) THEN
for k=1 to N
if close[k]=preciomaxmfi[1] then
zzmfi=k
if divmfi then
drawsegment(barindex[1], close[1], barindex[zzmfi2], close[zzmfi2]) coloured(155,0,0)style(dottedline,1)
endif
endif
next
endif
endif
IF (mimfi[1]<mimfi AND mimfi[1]<mimfi[2]) THEN
extremummfi22=mimfi[1]
extremummfi11=lowest[N](mimfi)
preciominmfi2=close[1]
preciominmfi=lowest[N](close)
IF(extremummfi22>extremummfi11 AND preciominmfi2<preciominmfi[1]) THEN
for k2=1 to N
if close[k2]=preciominmfi[1] then
zzmfi2=k2
if divmfi then
drawsegment(barindex[1], close[1],barindex[zzmfi2], close[zzmfi2]) coloured(155,0,0)style(line,3)
endif
endif
next
endif
endif
endif
if islastbarupdate then
DRAWTEXT("Bleu:macd",barindex+6,low-0.025*low,dialog,standard,10)coloured(0,0,155)
DRAWTEXT("Vert:rsi",barindex+6,low-0.05*low,dialog,standard,10)coloured(0,155,0)
DRAWTEXT("Rouge:mfi",barindex+6,low-0.075*low,dialog,standard,10)coloured(255,0,0)
endif
return
N=40///N is the number of bars to look back for a divergence. Normal values are 20-40. Must be the same in both indicators
miMACD = exponentialAverage[12](close)-exponentialAverage[26](close)
mirsi = RSI[14](close)
miOBV  = OBV(close)
mimfi=MoneyFlowIndex[14]
IF (BarIndex > 10+1+N) THEN
IF (miMACD[1]>miMACD AND miMACD[1]>miMACD[2]) THEN
extremum2=miMACD[1]
extremum1=highest[N](miMACD)
preciomax2=close[1]
preciomax=Highest[N](close)
IF(extremum2<extremum1 AND preciomax2>preciomax[1]) THEN
for i=1 to N
if mimacd[i]=extremum1 then
zzm=i
if divmacd then
drawsegment (barindex[1], mimacd[1],barindex[zzm], mimacd[zzm])coloured(0,0,155)style(dottedline,2)
DRAWPOINT(barindex[1], mimacd[1],1)coloured(0,0,155,100)
DRAWPOINT(barindex[zzm], mimacd[zzm],1)coloured(0,0,155,100)
endif
endif
next
endif
endif
IF (miMACD[1]<miMACD AND miMACD[1]<miMACD[2]) THEN
extremum22=miMACD[1]
extremum11=lowest[N](miMACD)
preciomin2=close[1]
preciomin=lowest[N](close)
IF(extremum22>extremum11 AND preciomin2<preciomin[1]) THEN
for i2=1 to N
if mimacd[i2]=extremum11[1] then
zzm2=i2
if divmacd then
drawsegment(barindex[1], mimacd[1], barindex[zzm2], mimacd[zzm2])coloured(0,0,155)style(line,2)
DRAWPOINT(barindex[1], mimacd[1],1)coloured(0,0,155,100)
DRAWPOINT(barindex[zzm2], mimacd[zzm2],1)coloured(0,0,155,100)
endif
endif
next
endif
endif
//////////////////////////////////////////////////
IF (mirsi[1]>mirsi AND mirsi[1]>mirsi[2]) THEN
extremumr2=mirsi[1]
extremumr1=highest[N](mirsi)
preciomaxr2=close[1]
preciomaxr=Highest[N](close)
IF(extremumr2<extremumr1 AND preciomaxr2>preciomaxr[1]) THEN
for j=1 to N
if mirsi[j]=extremumr1 then
zzr=j
if divrsi then
drawsegment (barindex[1], mirsi[1], barindex[zzr], mirsi[zzr])coloured(0,155,0)style(dottedline,2)
DRAWPOINT(barindex[1], mirsi[1],1)coloured(0,155,0,0)BORDERCOLOR(0,155,0)
DRAWPOINT(barindex[zzr], mirsi[zzr],1)coloured(0,155,0,0)BORDERCOLOR(0,155,0)
endif
endif
next
endif
endif
IF (mirsi[1]<mirsi AND mirsi[1]<mirsi[2]) THEN
extremumr22=mirsi[1]
extremumr11=lowest[N](mirsi)
preciominr2=close[1]
preciominr=lowest[N](close)
IF(extremumr22>extremumr11 AND preciominr2<preciominr[1]) THEN
for j2=1 to N
if mirsi[j2]=extremumr11[1] then
zzr2=j2
if divrsi then
drawsegment (barindex[1], mirsi[1], barindex[zzr2], mirsi[zzr2])coloured(0,155,0)style(line,2)
DRAWPOINT(barindex[1], mirsi[1],1)coloured(0,155,0,0)BORDERCOLOR(0,155,0)
DRAWPOINT(barindex[zzr2], mirsi[zzr2],1)coloured(0,155,0,0)BORDERCOLOR(0,155,0)
endif
endif
next
endif
endif
///////////////////////////////////////////////////
IF (mimfi[1]>mimfi AND mimfi[1]>mimfi[2]) THEN
extremummfi2=mimfi[1]
extremummfi1=highest[N](mimfi)
preciomaxmfi2=close[1]
preciomaxmfi=Highest[N](close)
IF(extremummfi2<extremummfi1 AND preciomaxmfi2>preciomaxmfi[1]) THEN
for k=1 to N
if mimfi[k]=extremumr1 then
zzmf=k
if divmfi then
drawsegment (barindex[1], mimfi[1], barindex[zzmf], mimfi[zzmf])coloured(155,0,0)style(dottedline,2)
DRAWPOINT(barindex[1], mimfi[1],1)coloured(255,255,255,0)BORDERCOLOR(155,0,0)
DRAWPOINT(barindex[zzmf], mimfi[zzmf],1)coloured(255,255,255,0)BORDERCOLOR(155,0,0)
endif
endif
next
endif
endif
IF (mimfi[1]<mimfi AND mimfi[1]<mimfi[2]) THEN
extremummfi22=mimfi[1]
extremummfi11=lowest[N](mimfi)
preciominmfi2=close[1]
preciominmfi=lowest[N](close)
IF(extremummfi22>extremummfi11 AND preciominmfi2<preciominmfi[1]) THEN
for k2=1 to N
if mimfi[k2]=extremummfi11[1] then
zzmf2=k2
if divmfi then
drawsegment (barindex[1], mimfi[1], barindex[zzmf2], mimfi[zzmf2])coloured(155,0,0)style(line,2)
DRAWPOINT(barindex[1], mimfi[1],1)coloured(255,255,255,0)BORDERCOLOR(155,0,0)
DRAWPOINT(barindex[zzmf2], mimfi[zzmf2],1)coloured(255,255,255,0)BORDERCOLOR(155,0,0)
endif
endif
next
endif
endif
endif
if islastbarupdate then
DRAWTEXT("Bleu:macd",barindex+6,20,dialog,standard,10)coloured(0,0,155)
DRAWTEXT("Vert:rsi",barindex+6,10,dialog,standard,10)coloured(0,155,0)
DRAWTEXT("Rouge:mfi",barindex+6,0,dialog,standard,10)coloured(255,0,0)
endif

return mimacd as "MACD",mirsi as "RSI",mimfi as"MFI"

.

Download
Filename: MACD-MFI-divergences-price.itf
Downloads: 119
Download
Filename: MACD-MFI-divergences-indicator.itf
Downloads: 125
jacquesgermain
jacquesgermain Veteran
Developer by day, aspiring writer by night. Still compiling my bio... Error 404: presentation not found.
Author’s Profile

Comments

Carlose
3 years ago
#

estoy de acuerdo con IASD Esta muy bien el MAD y el indicador en el precio no se ven bien, creo que es una cuestion de escalas gracias Jacques

emiliobercial
3 years ago
#

Thank you very much for sharing!

jacquesgermain
3 years ago
#

Hello IASD it's normal , when this occurs, uncheck RSI and MFI line and click then the MACD is showing clearly

IASD
3 years ago
#

Thank you very much for sharing the indicators it's amazing work, The MACD is not showing clearly It looks like a line

ProRealCode ProRealCode
Loading...