Moyenne des 5 derniers changements de direction de la moyenne du Guppy

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #174500 quote
    finplus
    Participant
    Master

    Bonjour,

    j’utilise l’indicateur suivant que j’ai un peu “arrangé” à ma sauce : il est construit à partir de l’indicateur Guppy.

    a = close
    c1 = ExponentialAverage[3](a)
    c2 = ExponentialAverage[5](a)
    c3 = ExponentialAverage[8](a)
    c4 = ExponentialAverage[10](a)
    c5 = ExponentialAverage[12](a)
    c6 = ExponentialAverage[15](a)
    
    GuppyCTMoy = (c1 + c2 + c3 + c4 + c5 + c6)/6
    
    c7 = ExponentialAverage[30](a)
    c8 = ExponentialAverage[35](a)
    c9 = ExponentialAverage[40](a)
    c10 = ExponentialAverage[45](a)
    c11 = ExponentialAverage[50](a)
    c12 = ExponentialAverage[60](a)
    
    GuppyLTMoy = (c7 + c8 + c9 + c10 + c11 + c12)/6
    
    Ecart = (GuppyCTMoy - GuppyLTMoy)
    
    T1 = c7 - C7[1]
    T2 = c8 - C8[1]
    T3 = c9 - C9[1]
    T4 = C10 - C10[1]
    T5 = c11 - C11[1]
    T6 = c12 - c12[1]
    
    Guppy = (T1 + T2 + T3 + T4 + T5 + T6)/6
    
    GuppyMoy = average[20](Guppy)*10
    
    Return ecart as "ecart", guppymoy as "guppymoy"

    en pièce jointe la représentation graphique.

    A partir de cet indicateur, je souhaiterai tracer une ligne horizontale qui serait calculé à partir des changements de la moyenne du Guppy uniquement lorsque celle-ci se retourne à la baisse et uniquement lorsque cette moyenne est au dessus de 0.

    J’ai mis les flèches rouges qui marquent les changements de direction de la moyenne du guppy. Mais je ne sais pas comment “recenser” les 5 derniers changements de direction de la moyenne du guppy sur les N dernières périodes (N = 50 par exemple).

    J’espère avoir été clair dans ma demande.

    Merci.

    Capture-décran-2021-08-01-à-15.45.13.png Capture-décran-2021-08-01-à-15.45.13.png Capture-décran-2021-08-01-à-16.00.42.png Capture-décran-2021-08-01-à-16.00.42.png
    #174505 quote
    JC_Bywan
    Moderator
    Master

    Moyenne des 5 derniers changements à la baisse étant positif de guppymoy, indépendamment du nombre de bougies en arrière (car rien ne dit que 5 va correspondre à un nombre limité défini à l’avance, ou alors il faut figer le nombre de bougies mais ne pas forcément en vouloir 5), représentée par ligne horizontale.

    Les lignes supplémentaires commentées 36à40 et 49à58 peuvent être décommentées si on veut vérifier la localisation des 5 dernières occurences utilisées.

    defparam DRAWONLASTBARONLY=true
    
    a = close
    c1 = ExponentialAverage[3](a)
    c2 = ExponentialAverage[5](a)
    c3 = ExponentialAverage[8](a)
    c4 = ExponentialAverage[10](a)
    c5 = ExponentialAverage[12](a)
    c6 = ExponentialAverage[15](a)
     
    GuppyCTMoy = (c1 + c2 + c3 + c4 + c5 + c6)/6
     
    c7 = ExponentialAverage[30](a)
    c8 = ExponentialAverage[35](a)
    c9 = ExponentialAverage[40](a)
    c10 = ExponentialAverage[45](a)
    c11 = ExponentialAverage[50](a)
    c12 = ExponentialAverage[60](a)
     
    GuppyLTMoy = (c7 + c8 + c9 + c10 + c11 + c12)/6
     
    Ecart = (GuppyCTMoy - GuppyLTMoy)
     
    T1 = c7 - C7[1]
    T2 = c8 - C8[1]
    T3 = c9 - C9[1]
    T4 = C10 - C10[1]
    T5 = c11 - C11[1]
    T6 = c12 - c12[1]
     
    Guppy = (T1 + T2 + T3 + T4 + T5 + T6)/6
     
    GuppyMoy = average[20](Guppy)*10
    
    if GuppyMoy<GuppyMoy[1] and GuppyMoy[1]>GuppyMoy[2] and GuppyMoy[1]>0 then
    //bar5=bar4
    //bar4=bar3
    //bar3=bar2
    //bar2=bar1
    //bar1=barindex[1]
    ch5=ch4
    ch4=ch3
    ch3=ch2
    ch2=ch1
    ch1=GuppyMoy[1]
    chmoy=(ch1+ch2+ch3+ch4+ch5)/5
    endif
    if ch5<>0 then
    //DRAWSEGMENT(bar5-5, ch5, bar5+5, ch5) style(line,2)
    //DRAWSEGMENT(bar4-5, ch4, bar4+5, ch4) style(line,2)
    //DRAWSEGMENT(bar3-5, ch3, bar3+5, ch3) style(line,2)
    //DRAWSEGMENT(bar2-5, ch2, bar2+5, ch2) style(line,2)
    //DRAWSEGMENT(bar1-5, ch1, bar1+5, ch1) style(line,2)
    //DRAWTEXT("5", bar5, 0)
    //DRAWTEXT("4", bar4, 0)
    //DRAWTEXT("3", bar3, 0)
    //DRAWTEXT("2", bar2, 0)
    //DRAWTEXT("1", bar1, 0)
    
    DRAWHLINE(chmoy)
    endif
     
    Return ecart as "ecart", guppymoy as "guppymoy"
    #174512 quote
    finplus
    Participant
    Master

    Bonsoir,

    merci pour votre réponse. Je mets en pièce jointe un aperçu de l’indicateur en UT 4 heures sur le CAC.  C’est un début de réponse mais je voudrais juste une ligne qui serait la moyenne des 5 derniers changements de direction de la moyenne. Merci pour votre aide.

    Capture-décran-2021-08-01-à-18.59.17.png Capture-décran-2021-08-01-à-18.59.17.png
    #174516 quote
    JC_Bywan
    Moderator
    Master

    Je pense que vous avez probablement juste rajouté seulement certaines lignes à partir de la 35 au lieu de copier-coller le tout, ce qui ferait qu’il vous manque la ligne 1 qui permettait de ne tracer que la dernière horizontale valide

    #174517 quote
    finplus
    Participant
    Master

    Rebonsoir,

    autant pour moi. J’avais oublié la 1ère ligne du programme. Cela a l’air de fonctionner. Je continue les tests et vous reviens.

    Merci encore pour votre aide.

    Capture-décran-2021-08-01-à-19.39.57.png Capture-décran-2021-08-01-à-19.39.57.png
    #174530 quote
    finplus
    Participant
    Master

    bonsoir, si vous avez un peu de temps, pourriez-vous coder SVP la partie opposée c’est-à-dire lorsque la moyenne du guppy se retourne à la hausse et uniquement lorsqu’elle est au-dessous de 0?

    merci d’avance et bonne fin de week-end.

    #174533 quote
    JC_Bywan
    Moderator
    Master

    Voilà

    defparam DRAWONLASTBARONLY=true
    
    a = close
    c1 = ExponentialAverage[3](a)
    c2 = ExponentialAverage[5](a)
    c3 = ExponentialAverage[8](a)
    c4 = ExponentialAverage[10](a)
    c5 = ExponentialAverage[12](a)
    c6 = ExponentialAverage[15](a)
     
    GuppyCTMoy = (c1 + c2 + c3 + c4 + c5 + c6)/6
     
    c7 = ExponentialAverage[30](a)
    c8 = ExponentialAverage[35](a)
    c9 = ExponentialAverage[40](a)
    c10 = ExponentialAverage[45](a)
    c11 = ExponentialAverage[50](a)
    c12 = ExponentialAverage[60](a)
     
    GuppyLTMoy = (c7 + c8 + c9 + c10 + c11 + c12)/6
     
    Ecart = (GuppyCTMoy - GuppyLTMoy)
     
    T1 = c7 - C7[1]
    T2 = c8 - C8[1]
    T3 = c9 - C9[1]
    T4 = C10 - C10[1]
    T5 = c11 - C11[1]
    T6 = c12 - c12[1]
     
    Guppy = (T1 + T2 + T3 + T4 + T5 + T6)/6
     
    GuppyMoy = average[20](Guppy)*10
    
    if GuppyMoy<GuppyMoy[1] and GuppyMoy[1]>GuppyMoy[2] and GuppyMoy[1]>0 then
    ch5=ch4
    ch4=ch3
    ch3=ch2
    ch2=ch1
    ch1=GuppyMoy[1]
    chmoy=(ch1+ch2+ch3+ch4+ch5)/5
    endif
    if ch5<>0 then
    DRAWHLINE(chmoy)
    endif
    
    if GuppyMoy>GuppyMoy[1] and GuppyMoy[1]<GuppyMoy[2] and GuppyMoy[1]<0 then
    cb5=cb4
    cb4=cb3
    cb3=cb2
    cb2=cb1
    cb1=GuppyMoy[1]
    cbmoy=(cb1+cb2+cb3+cb4+cb5)/5
    endif
    if cb5<>0 then
    DRAWHLINE(cbmoy)
    endif
     
    Return ecart as "ecart", guppymoy as "guppymoy"
    #174534 quote
    finplus
    Participant
    Master

    Merci !

    Excellente soirée.

    JC_Bywan thanked this post
    #174583 quote
    finplus
    Participant
    Master

    Un petit retour pour indiquer que cela répond parfaitement à mon besoin.

    Est-il possible de ne pas mentionner dans le code  la fonction DRAWHLINE mais d’indiquer la valeur correspondante dans la dernière ligne “return” de façon à ce que je puisse la configurer facilement en cliquant sur “configurer”?

    j’espère avoir été clair.

    Merci.

    #174616 quote
    JC_Bywan
    Moderator
    Master

    C’est bien sûr possible, dans ce cas, les lignes ne seront plus horizontales car étant retournées via la ligne “return”, on aura alors l’historique de leurs emplacements. Il suffit de supprimer les lignes en drawhline, et aussi la première ligne drawonlastbaronly. Au passage j’ai remplacé des noms de variables pour que leur nom soit plus proche du nom affiché à l’écran via as “” de la ligne return. Cela vous donne:

    a = close
    c1 = ExponentialAverage[3](a)
    c2 = ExponentialAverage[5](a)
    c3 = ExponentialAverage[8](a)
    c4 = ExponentialAverage[10](a)
    c5 = ExponentialAverage[12](a)
    c6 = ExponentialAverage[15](a)
     
    GuppyCTMoy = (c1 + c2 + c3 + c4 + c5 + c6)/6
     
    c7 = ExponentialAverage[30](a)
    c8 = ExponentialAverage[35](a)
    c9 = ExponentialAverage[40](a)
    c10 = ExponentialAverage[45](a)
    c11 = ExponentialAverage[50](a)
    c12 = ExponentialAverage[60](a)
     
    GuppyLTMoy = (c7 + c8 + c9 + c10 + c11 + c12)/6
     
    Ecart = (GuppyCTMoy - GuppyLTMoy)
     
    T1 = c7 - C7[1]
    T2 = c8 - C8[1]
    T3 = c9 - C9[1]
    T4 = C10 - C10[1]
    T5 = c11 - C11[1]
    T6 = c12 - c12[1]
     
    Guppy = (T1 + T2 + T3 + T4 + T5 + T6)/6
     
    GuppyMoy = average[20](Guppy)*10
    
    if GuppyMoy<GuppyMoy[1] and GuppyMoy[1]>GuppyMoy[2] and GuppyMoy[1]>0 then
    RetB5=RetB4
    RetB4=RetB3
    RetB3=RetB2
    RetB2=RetB1
    RetB1=GuppyMoy[1]
    RetBmoy=(RetB1+RetB2+RetB3+RetB4+RetB5)/5
    endif
    
    if GuppyMoy>GuppyMoy[1] and GuppyMoy[1]<GuppyMoy[2] and GuppyMoy[1]<0 then
    RetH5=RetH4
    RetH4=RetH3
    RetH3=RetH2
    RetH2=RetH1
    RetH1=GuppyMoy[1]
    RetHmoy=(RetH1+RetH2+RetH3+RetH4+RetH5)/5
    endif
     
    Return ecart as "ecart", guppymoy as "guppymoy", RetBmoy as "Moyenne 5 derniers retournements baissiers", RetHmoy as "Moyenne 5 derniers retournements haussiers"
    #174622 quote
    finplus
    Participant
    Master

    Un grand merci.

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

Moyenne des 5 derniers changements de direction de la moyenne du Guppy


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
finplus @finplus Participant
Summary

This topic contains 10 replies,
has 2 voices, and was last updated by finplus
4 years, 7 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 08/01/2021
Status: Active
Attachments: 4 files
Logo Logo
Loading...