Codage d'un stop loss combiné avec un stop suiveur

Viewing 5 posts - 16 through 20 (of 20 total)
  • Author
    Posts
  • #125054 quote
    MonsieurZ
    Participant
    Junior

    Bonjour à tous, je me permets de répondre sur ce vieux sujet pour obtenir de l’aide.

    J’essaie une stratégie de convergence de couleur Heikin-Ashi sur 3 UT pour ça, pas de problème. (Je mets d’ailleurs le code si ça peut servir à d’autres)

    Cependant je ne parviens pas à configurer un stop suiveur derrière l’ouverture de l’avant dernière bougie Heikin-Ashi. Je ne sais même pas vraiment vérifier si ce que j’ai fait fonctionne :-/

    Merci d’avance pour votre aide précieuse

    timeframe(3000 minutes)
    //heikin-ashi pour UT2
    xCloseUT3 = (Open+High+Low+Close)/4
    if(barindex>2) then
    xOpenUT3 = (xOpenUT3[1] + xCloseUT3[1])/2
    endif
    //condition d'achat pour UT3
    HAVertUT3 = xCloseUT3>xOpenUT3 AND xCloseUT3[1]<xOpenUT3[1]
    //condition de vente pour UT3
    HARougeUT3 = xCloseUT3<xOpenUT3 AND xCloseUT3[1]>xOpenUT3[1]
    
    
    timeframe(300 minutes)
    
    //heikin-ashi pour UT2
    xCloseUT2 = (Open+High+Low+Close)/4
    if(barindex>2) then
    xOpenUT2 = (xOpenUT2[1] + xCloseUT2[1])/2
    endif
    //condition d'achat pour UT2
    HAVertUT2 = xCloseUT2>xOpenUT2 AND xCloseUT2[1]<xOpenUT2[1]
    //condition de vente pour UT2
    HARougeUT2 = xCloseUT2<xOpenUT2 AND xCloseUT2[1]>xOpenUT2[1]
    
    
    timeframe(default)
    xCloseUT1 = (Open+High+Low+Close)/4
    if(barindex>2) then
    xOpenUT1 = (xOpenUT1[1] + xCloseUT1[1])/2
    endif
    //condition d'achat pour UT1
    HAVertUT1 = xCloseUT1>xOpenUT1 AND xCloseUT1[1]<xOpenUT1[1]
    //condition de vente pour UT1
    HARougeUT1 = xCloseUT1<xOpenUT1 AND xCloseUT1[1]>xOpenUT1[1]
    
    
    //on achète si toutes les UT convergentes
    if HAVertUT2 and HAVertUT3 and HAVertUT1 then
    BUY 1 SHARE AT MARKET
    endif
    
    //on vend si toutes les UT convergentes 
    if HARougeUT2 and HARougeUT3 and HARougeUT1 then
    SELLSHORT 1 SHARE AT MARKET
    endif
    
    //stop suiveur derrière l'avant dernière bougie <------------------------------- BESOIN DE VOUS A PARTIR D'ICI
    IF LONGONMARKET THEN
    SL = xOpenUT1[1]
    SELL AT SL STOP
    ENDIF
    
    IF SHORTONMARKET THEN
    SL = xOpenUT[1]
    BUY AT SL STOP
    ENDIF
    
    
    
    GRAPHONPRICE SL coloured(178,34,34) AS "SL"
    bertrandpinoy thanked this post
    #125100 quote
    Nicolas
    Keymaster
    Master

    Pour fermer une position de vente à découvert, il faut utiliser l’instruction EXITSHORT (remplacer BUY à la ligne 55).

    Avec ton GRAPHONPRICE, tu devrais correctement visualiser ton stop suiveur sur le graphique du prix te permettant de débugger le calcul de ce niveau si nécessaire. Sans avoir testé par moi même, après lecture du code, l’ensemble me semble correct.

    #125214 quote
    MonsieurZ
    Participant
    Junior

    Bonjour Nicolas,

    Merci pour ta réponse. En effet, l’erreur était EXITSHORT à la place de BUY.

     

    J’en profite pour te féliciter pour ton excellent travail sur le forum et ailleurs.

    #125268 quote
    bertrandpinoy
    Participant
    Veteran

    perso j ai ce message d erreur…

    #125287 quote
    MonsieurZ
    Participant
    Junior

    Salut,

    C’est la fin du code qui pose problème. je mets une version corrigée.

    timeframe(3000 minutes)
    //heikin-ashi pour UT2
    xCloseUT3 = (Open+High+Low+Close)/4
    if(barindex>2) then
    xOpenUT3 = (xOpenUT3[1] + xCloseUT3[1])/2
    endif
    //condition d'achat pour UT3
    HAVertUT3 = xCloseUT3>xOpenUT3 AND xCloseUT3[1]<xOpenUT3[1]
    //condition de vente pour UT3
    HARougeUT3 = xCloseUT3<xOpenUT3 AND xCloseUT3[1]>xOpenUT3[1]
     
     
    timeframe(300 minutes)
     
    //heikin-ashi pour UT2
    xCloseUT2 = (Open+High+Low+Close)/4
    if(barindex>2) then
    xOpenUT2 = (xOpenUT2[1] + xCloseUT2[1])/2
    endif
    //condition d'achat pour UT2
    HAVertUT2 = xCloseUT2>xOpenUT2 AND xCloseUT2[1]<xOpenUT2[1]
    //condition de vente pour UT2
    HARougeUT2 = xCloseUT2<xOpenUT2 AND xCloseUT2[1]>xOpenUT2[1]
     
     
    timeframe(default)
    xCloseUT1 = (Open+High+Low+Close)/4
    if(barindex>2) then
    xOpenUT1 = (xOpenUT1[1] + xCloseUT1[1])/2
    endif
    //condition d'achat pour UT1
    HAVertUT1 = xCloseUT1>xOpenUT1 AND xCloseUT1[1]<xOpenUT1[1]
    //condition de vente pour UT1
    HARougeUT1 = xCloseUT1<xOpenUT1 AND xCloseUT1[1]>xOpenUT1[1]
     
     
    //on achète si toutes les UT convergentes
    if HAVertUT2 and HAVertUT3 and HAVertUT1 then
    BUY 1 SHARE AT MARKET
    endif
     
    //on vend si toutes les UT convergentes 
    if HARougeUT2 and HARougeUT3 and HARougeUT1 then
    SELLSHORT 1 SHARE AT MARKET
    endif
     
    //stop suiveur derrière l'avant dernière bougie
    IF LONGONMARKET THEN
    SL = xOpenUT1[1]
    SELL AT SL STOP
    ENDIF
     
    IF SHORTONMARKET THEN
    SL = xOpenUT1[1]
    EXITSHORT AT SL STOP
    ENDIF
     
     
     
    GRAPHONPRICE SL coloured(178,34,34) AS "SL"
    Nicolas thanked this post
Viewing 5 posts - 16 through 20 (of 20 total)
  • You must be logged in to reply to this topic.

Codage d'un stop loss combiné avec un stop suiveur


Support ProOrder

New Reply
Author
author-avatar
frooggs @frooggs Participant
Summary

This topic contains 19 replies,
has 7 voices, and was last updated by MonsieurZ
5 years, 9 months ago.

Topic Details
Forum: Support ProOrder
Language: French
Started: 03/30/2016
Status: Active
Attachments: 3 files
Logo Logo
Loading...