Indicateur achat vente avec MM Hull pas au point :(

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #79944 quote
    Detroit
    Participant
    Junior

    Bonjour,

    je débute en programmation et je cherche à coder un indicateur qui me donnerait des signaux achat/vente en s’appuyant sur des moyennes mobiles de hull de plusieurs durées. Les moyennes mobiles de hull ne sont malheureusement pas dispo dans probuilder, j’ai récupéré la formule sur ce site.

    Mon code ne fonctionne qu’à moitié car il m’envoie des signaux souvent anticipés d’une bougie. Cela peut se gérer sur une UT courte mais lorsque l’on travaille en UT 1 heure ou 4 heures, une bougie d’avance c’est beaucoup trop. L’indicateur m’envoie également quelques faux signaux.

    L’idée est qu’ un signal d’achat apparait lorsque les moyennes mobiles de hull 100 et 500 sont croissantes, que la moyenne mobile de hull 20 descend et qu’elle redevient croissante. Le signal devrait apparaitre à la bougie qui a provoqué le changement de direction. Mais non…:)

    C’est bien sur l’inverse pour le signal de vente.

    Ci-dessous le code :

    signalBuy = 0
    signalSell = 0
    
    P = 20
    demiP = round(P/2)
    temp = 2*WeightedAverage[demiP](close) - WeightedAverage[P](close)
    racineP = round(SQRT(P))
    MMHULL20 = WeightedAverage[racineP](temp)
    
    
    PA = 100
    demiPA = round(PA/2)
    temp = 2*WeightedAverage[demiPA](close) - WeightedAverage[PA](close)
    racinePA = round(SQRT(PA))
    MMHULL100 = WeightedAverage[racinePA](temp)
    
    PB = 500
    demiPB = round(PB/2)
    temp = 2*WeightedAverage[demiPB](close) - WeightedAverage[PB](close)
    racinePB = round(SQRT(PB))
    MMHULL500 = WeightedAverage[racinePB](temp)
    
    
    a1 = MMHULL20[1] < MMHULL20[2]
    a2 = MMHULL20[1] > MMHULL20[2]
    
    b1 = MMHULL20 > MMHULL20[1]
    b2 = MMHULL20 < MMHULL20[1]
    
    c1 = MMHULL100 > MMHULL100[2] AND MMHULL100[2] > MMHULL100[4]
    c2 = MMHULL100 < MMHULL100[2] AND MMHULL100[2] < MMHULL100[4]
    
    d1 = MMHULL500 > MMHULL500[2] AND MMHULL500[2] > MMHULL500[4]
    d2 = MMHULL500 < MMHULL500[2] AND MMHULL500[2] < MMHULL500[4]
    
    IF a1 AND b1 AND c1 AND d1 THEN
    signalBuy = 10
    signalSell = 0
    ELSIF a2 AND b2 AND c2 AND d2 THEN
    signalSell = 10
    signalBuy= 0
    ENDIF
    
    RETURN signalBuy COLOURED (0,153,204) AS "Signal Achat",signalSell COLOURED (220,100,100) AS "Signal Vente"
    

     

    Si quelqu’un a identifié d’où peut venir mon erreur, je suis preneur.

    Merci

    #79957 quote
    Nicolas
    Keymaster
    Master

    Le problème vient  du fait que tu as utilisé plusieurs fois la variable nommée ‘temp’ dans les calculs des moyennes mobiles de Hull, je les ai donc renommée indépendamment.

    (j’ai modifié l’histogramme par des flèches sur le graphique, plus facile pour moi à débugger).

    //signalBuy = 0
    //signalSell = 0
    
    P = 20
    demiP = round(P/2)
    temp = 2*WeightedAverage[demiP](close) - WeightedAverage[P](close)
    racineP = round(SQRT(P))
    MMHULL20 = WeightedAverage[racineP](temp)
    
    
    PA = 100
    demiPA = round(PA/2)
    tempA = 2*WeightedAverage[demiPA](close) - WeightedAverage[PA](close)
    racinePA = round(SQRT(PA))
    MMHULL100 = WeightedAverage[racinePA](tempA)
    
    PB = 500
    demiPB = round(PB/2)
    tempB = 2*WeightedAverage[demiPB](close) - WeightedAverage[PB](close)
    racinePB = round(SQRT(PB))
    MMHULL500 = WeightedAverage[racinePB](tempB)
    
    
    a1 = MMHULL20[1] < MMHULL20[2]
    a2 = MMHULL20[1] > MMHULL20[2]
    
    b1 = MMHULL20 > MMHULL20[1]
    b2 = MMHULL20 < MMHULL20[1]
    
    c1 = MMHULL100 > MMHULL100[2] AND MMHULL100[2] > MMHULL100[4]
    c2 = MMHULL100 < MMHULL100[2] AND MMHULL100[2] < MMHULL100[4]
    
    d1 = MMHULL500 > MMHULL500[2] AND MMHULL500[2] > MMHULL500[4]
    d2 = MMHULL500 < MMHULL500[2] AND MMHULL500[2] < MMHULL500[4]
    
    IF a1 AND b1 AND c1 AND d1 THEN
    //signalBuy = 10
    //signalSell = 0
    drawarrowup(barindex,low) coloured(0,200,0)
    ELSIF a2 AND b2 AND c2 AND d2 THEN
    //signalSell = 10
    //signalBuy= 0
    drawarrowdown(barindex,high) coloured(200,0,0)
    ENDIF
    
    RETURN //signalBuy COLOURED (0,153,204) AS "Signal Achat",signalSell COLOURED (220,100,100) AS "Signal Vente"
    Detroit thanked this post
    signaux-de-trading-moyennes-mobiles-de-hull.png signaux-de-trading-moyennes-mobiles-de-hull.png
    #79960 quote
    Detroit
    Participant
    Junior

    C’est génial ! 🙂

    Cela parait évident… Une fois qu’on le sait.

    Merci beaucoup Nicolas pour ta réponse et ta rapidité.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Indicateur achat vente avec MM Hull pas au point :(


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
Detroit @detroit Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by Detroit
7 years, 6 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 09/07/2018
Status: Active
Attachments: 1 files
Logo Logo
Loading...