Alerte divergence MACD

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #226925 quote
    guillaumeaco
    Participant
    New

    Bonjour,

    J’ai installé l’indicateur de divergence ci-dessous trouvé dans le forum et je vous en remercie. Es t-il possible de mettre un système d’alerte quand une divergence est détectée ?

    MACD Divergences on price and indicator

    Merci pour votre aide.

    #226943 quote
    jacquesgermain
    Participant
    Senior

    Bonjour

    alerte non ce n’est pas possible mais les trouver à l’aide d’un détecteur (screener) oui , voir ci après ce screener :

    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)
    signalh=0
    signalb=0
    IF (BarIndex > 10+1+N) THEN
    //we look for bearish divergences
    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
    //zz=i
    signalb=1
    endif
    next
    
    endif
    endif
    //we look for bullish divergences
    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
    //zz2=i2
    signalh=1
    endif
    next
    endif
    endif
    endif
    screener [signalh=1 or signalb=1](signalh as "divhaussiere",signalb as "divbaissiere")
    
    //////////////////////////////////////////////
    #226944 quote
    guillaumeaco
    Participant
    New

    Merci pour votre retour.

    J’aurais aimé mettre l’indicateur MACD zéro retard à la place du MACD dans le code de la divergence.

    Savez-vous comment faire ?

    Cordialement

    #226952 quote
    jacquesgermain
    Participant
    Senior

    ok  voici ci après l’indicateur avec macd zéro retard

    ///////////////////////////////////////////////////////////
    
    // MACD divergences on price
    //by Jose Callao
    // twitter @jose7674
    // attach this indicator to the chart
    
    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
    // 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)
    
    IF (BarIndex > 10+1+N) THEN
    //we look for bearish divergences
    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
    zz=i
    drawsegment (barindex[1], mimacd[1], barindex[zz], mimacd[zz]) coloured(200,0,0)
    endif
    next
    
    endif
    endif
    //we look for bullish divergences
    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
    zz2=i2
    drawsegment(barindex[1], close[1], barindex[zz2], close[zz2]) coloured(0,200,0)
    endif
    next
    endif
    endif
    endif
    return miMACD
    
    //////////////////////////////////////////////
    #226954 quote
    guillaumeaco
    Participant
    New

    Merci pour votre retour rapide.

    Par contre, je n’ai pas les divergences baissières comme pour le MACD. Je vous mets un screen shot où on voit la différence ?

    Savez vous pourquoi ?

    #226959 quote
    jacquesgermain
    Participant
    Senior

    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)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)
    endif
    next
    endif
    endif
    IF (mimacd[1]>mimacd AND mimacd[1]>mimacd[2]) THEN
    rsiextremB2=mimacd[1]
    rsiextremB1=highest[N](mimacd)
    rsipmaxB2=close[1]
    rsipmaxB=Highest[N](close)
    IF(rsiextremB2=rsiextremB1 AND rsipmaxB2>rsipmaxB[1]) THEN
    for rsik=1 to N
    if close[rsik]=rsipmaxB[1] then
    rsizzmB=rsik
    if newclose[1]<newclose[rsizzmB] then
    signalrsi=-2
    flag=1
    DRAWTEXT("c",barindex[1], mimacd[1],dialog,bold,10)coloured(0,0,180)
    drawsegment (barindex[1], mimacd[1], barindex[rsizzmB],mimacd[rsizzmB]) coloured(150,0,0)style(dottedline,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)
    endif
    next
    endif
    endif
    IF (mimacd[1]<mimacd AND mimacd[1]<mimacd[2]) THEN
    rsiextremC2=mimacd[1]
    rsiextremC1=lowest[N](mimacd)
    rsipminC2=close[1]
    rsipminC=Lowest[N](close)
    IF(rsiextremC2=rsiextremC1 AND rsipminC2>rsipminC[1]) THEN
    for rsil=1 to N
    if close[rsil]=rsipminC[1] then
    rsizzmC=rsil
    DRAWTEXT("c",barindex[1], mimacd[1],dialog,bold,10)coloured(0,0,180)
    drawsegment (barindex[1], mimacd[1], barindex[rsizzmC],mimacd[rsizzmC]) coloured(150,0,0)style(line,1)
    endif
    next
    endif
    endif
    
    return mimacd as "mimacd"
    #226960 quote
    jacquesgermain
    Participant
    Senior
    prendre celui ci que je viens de réviser

    //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)
    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)
    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)
    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)
    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)
    endif
    next
    endif
    endif

    return mimacd as “mimacd”

    #226964 quote
    guillaumeaco
    Participant
    New

    Merci pour vos retours rapides.

    Je vais regarder ça.

    #227173 quote
    Alai-n
    Participant
    Veteran

    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"
    
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

Alerte divergence MACD


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
Summary

This topic contains 8 replies,
has 3 voices, and was last updated by Alai-n
2 years ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 01/26/2024
Status: Active
Attachments: 3 files
Logo Logo
Loading...