Bonjour,
Pour déclencher des Alertes sonores via la Plateforme, utilisez cette version… Ouvrir le code dans une fenêtre indépendante sous le graphique des prix!
//ok ci après rectifié l’erreur originelle et j’ai rajouté les divergences cachées
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
if close>open then
newclose=close
newopen=open
endif
if close<= open then
newclose=open
newopen=close
endif
//using any other indicator is as easy as changing the values
// MACD ZERO LAG
// p= variable macd zerolag : 12 par défaut
// q= variable signal : 26 par défaut
// r= variable macd - signal : 9 par défaut // mettre histogramme
p = 12
q = 26
r = 9
z1=DEMA[p](close)
z2 =dema[q](close)
e= z1 - z2
z3=DEMA[r](e)
f=z3
g=e-f
miMACD =g// exponentialAverage[12](close) - exponentialAverage[26](close)
///
ALERTE = 0
///
IF (mimacd[1]>mimacd AND mimacd[1]>mimacd[2]) THEN
extremumr2=mimacd[1]
extremumr1=highest[N](mimacd)
preciomaxr2=close[1]
preciomaxr=Highest[N](close)
IF(extremumr2<extremumr1 AND preciomaxr2>preciomaxr[1]) THEN
for j=1 to N
if mimacd[j]=extremumr1 then
zzr=j
//drawsegment (barindex[1], mimacd[1], barindex[zzr], mimacd[zzr])coloured(0,155,0)style(dottedline,2)
//DRAWPOINT(barindex[1], mimacd[1],1)coloured(0,155,0,0)BORDERCOLOR(0,155,0)
//DRAWPOINT(barindex[zzr], mimacd[zzr],1)coloured(0,155,0,0)BORDERCOLOR(0,155,0)
ALERTE = -1
endif
next
endif
endif
IF (mimacd[1]>mimacd AND mimacd[1]>mimacd[2]) THEN
macdextremB2=mimacd[1]
macdextremB1=highest[N](mimacd)
macdpmaxB2=close[1]
macdpmaxB=Highest[N](close)
IF(macdextremB2=macdextremB1 AND macdpmaxB2>macdpmaxB[1]) THEN
for macdk=1 to N
if close[macdk]=macdpmaxB[1] then
macdzzmB=macdk
if newclose[1]<newclose[macdzzmB] then
signalmacd=-2
flag=1
//DRAWTEXT("c",barindex[1], mimacd[1],dialog,bold,10)coloured(0,0,180)
//drawsegment (barindex[1], mimacd[1], barindex[macdzzmB],mimacd[macdzzmB]) coloured(150,0,0)style(dottedline,1)
ALERTE = -1
endif
endif
next
endif
endif
IF (mimacd[1]<mimacd AND mimacd[1]<mimacd[2]) THEN
extremumr22=mimacd[1]
extremumr11=lowest[N](mimacd)
preciominr2=close[1]
preciominr=lowest[N](close)
IF(extremumr22>extremumr11 AND preciominr2<preciominr[1]) THEN
for j2=1 to N
if mimacd[j2]=extremumr11[1] then
zzr2=j2
//drawsegment (barindex[1], mimacd[1], barindex[zzr2], mimacd[zzr2])coloured(0,155,0)style(line,2)
//DRAWPOINT(barindex[1], mimacd[1],1)coloured(0,155,0,0)BORDERCOLOR(0,155,0)
//DRAWPOINT(barindex[zzr2], mimacd[zzr2],1)coloured(0,155,0,0)BORDERCOLOR(0,155,0)
ALERTE = 1
endif
next
endif
endif
IF (mimacd[1]<mimacd AND mimacd[1]<mimacd[2]) THEN
macdextremC2=mimacd[1]
macdextremC1=lowest[N](mimacd)
macdpminC2=close[1]
macdpminC=Lowest[N](close)
IF(macdextremC2=macdextremC1 AND macdpminC2>macdpminC[1]) THEN
for macdl=1 to N
if close[macdl]=macdpminC[1] then
macdzzmC=macdl
//DRAWTEXT("c",barindex[1], mimacd[1],dialog,bold,10)coloured(0,0,180)
//drawsegment (barindex[1], mimacd[1], barindex[macdzzmC],mimacd[macdzzmC]) coloured(150,0,0)style(line,1)
ALERTE = 1
endif
next
endif
endif
return ALERTE as "ALERTE"//, mimacd as "mimacd"