Stop Donchian et TP trailer

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #62512 quote
    FREDNC
    Participant
    Senior

    Bonjour, je cherche a mettre en place une stratégie  basé sur le canal de Donchian pour le Stop en remplacement du SL classic.

    A la suite, quand le trade se passe bien on enclenche un Stop trailler (en sortie de canal opposé au stop) en position de breakeven et on traille serré jusqu’à ce que le court se retourne et sortir en gain. j’ai trouvez plusieurs exemples de prog sur le site et j’ai associer un stop Dochiant avec un stop trailler. Ca marche très bien en backtest. Par contre, quand on veut mettre en place le robot (via IG en réel) j’ai le message suivant qui me dis que ce n’est pas possible car mon système peut engendrer une clôture partiel de position…. franchement je vois pas ça dans mon code ???  quelqu’un pourrait-il m’aider? Par avance merci

    POSITIONSIZE=1
    
    Conditions d'achat divers
    
    BUY POSITIONSIZE CONTRACT AT MARKET
    
    + le stop et le trailler ci-dessous
    
    
    //stop loss Donchian
    DC=70/
    CDH=Highest[DC](high)
    CDB=Lowest[DC](low)
    if longonmarket then
    sell POSITIONSIZE perpoint at cDB[1] stop //
    laststop = cDB[1]
    endif
    if shortonmarket then
    exitshort POSITIONSIZE perpoint at cDH[1] stop
    laststop = cDH[1]
    endif
    if onmarket then
    sell at laststop stop//laststop
    exitshort at laststop stop//laststop
    endif
    
    //tailing stop function basé surDonchian
    
    trailingstart = (CDH[1])//10 trailing will start @trailinstart points profit
    trailingstartV = (CDB[1])//10 trailing will start @trailinstart points profit
    trailingstep = (CDH[1])-((CDB[1])/2) //trailing step to move the "stoploss"
    trailingstepV = (CDB[1])-((CDH[1])/2) //trailing step to move the "stoploss"
    
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
    
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstartV*pipsize THEN
    newSL = tradeprice(1)-trailingstepV*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstepV*pipsize THEN
    newSL = newSL-trailingstepV*pipsize
    ENDIF
    ENDIF
    
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
    #62531 quote
    JC_Bywan
    Moderator
    Master

    Bonjour, merci de respecter les consignes du petit cadre fond jaune notamment d’utiliser le bouton “insert PRT code” normalement situé à droite de la première ligne d’icones dans l’éditeur de message. Je réédite le message pour vous cette fois-ci pour changer le format, afin que les autres membres notamment ceux qui savent lire le code très vite grâce au format de code PRT puisse mieux vous aider au lieu de zapper votre message. Merci de penser à l’avenir à l’usage du bon format.

    #62537 quote
    FREDNC
    Participant
    Senior

    Merci, je débute et j’ignorai cette règle.

    #62554 quote
    Nicolas
    Keymaster
    Master

    Il faudrait supprimer POSITIONSIZE aux lignes 15 et 19. ProOrder interprète une sortie partielle (qui n’est pas possible avec IG), même si POSITIONSIZE équivaut à l’ensemble de la position.

    #62606 quote
    FREDNC
    Participant
    Senior

    Merci Nicolas pour ta réponse.

    J’ai déjà tester en supprimant POSITIONSIZE de tout le programme, mais ça ne marche toujours pas. j’ai essaye de mettre juste sale et saleshort sans aucun Chiffre mais dans ce cas la le code est en erreur…. je suis un peu perdu, ça dépasse me compétence. Je pense que ce qui géne pro-Order c’est qu’on face référence à une taille de position et non la position en entier mais j’aurais besoin d’aide pour modifier le code. ci dessous le nouveau code qui ne fonction toujours pas même les dernières modification. Merci de voir ce que vous pouvez faire.

    //-------------------------------------------------------------------------
    // Code principal : EurUsdM5 ICT 76% 2.33% 3/13
    //-------------------------------------------------------------------------
    // Définition des paramètres du code
    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
    
    
    // Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position avant l'heure spécifiée
    noEntryBeforeTime = 085500//080000
    timeEnterBefore = time >= noEntryBeforeTime
    
    // Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position après l'heure spécifiée
    noEntryAfterTime = 182500//200000
    timeEnterAfter = time < noEntryAfterTime
    
    // Empêche le système de placer de nouveaux ordres sur les jours de la semaine spécifiés
    daysForbiddenEntry = OpenDayOfWeek = 1 OR OpenDayOfWeek = 6 //0 ou 6 et 0
    
    // Conditions pour ouvrir une position acheteuse
    indicator1 = Stochastic[170,4](close) // 127,4 ou [128,8]
    c1 = (indicator1 > 60)//58
    indicator2 = (DHigh(1) + DLow(1) + DClose(1))/3
    c2 = (close > indicator2)
    indicator3 = RSI[3](close)//5 7
    c3 = (indicator3 CROSSES OVER 18)//30
    
    IF (c1 AND c2) AND c3 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions pour fermer une position acheteuse
    indicator4 = RSI[7](close)//7 n'apporte rien
    c4 = (indicator4 CROSSES UNDER 70)//70 n'apporte rien
    
    IF c4 THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions pour ouvrir une position en vente à découvert
    indicator6 = (DHigh(1) + DLow(1) + DClose(1))/3
    c4 = (close < indicator6)
    indicator6b = Stochastic[130,10](close) // 111,8 138,8
    c5 = (indicator6b < 28)// 35 50
    indicator7 = RSI[12](close)//7
    c6 = (indicator7 CROSSES UNDER 60)//72
    
    IF c4 AND c5 AND c6 AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
    SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    
    // Conditions pour fermer une position en vente à découvert
    indicator8 = RSI[12](close)//7
    c8 = (indicator8 CROSSES OVER 30)//30 n'apporte rien
    
    IF c8 THEN
    EXITSHORT AT MARKET
    ENDIF
    
    //stop loss Donchian
    DC=70//80
    
    CDH=Highest[DC](high)
    CDB=Lowest[DC](low)
    if longonmarket then
    sell 1 perpoint at cDB[1] stop //
    laststop = cDB[1]
    endif
    if shortonmarket then
    exitshort 1 perpoint at cDH[1] stop
    laststop = cDH[1]
    endif
    if onmarket then
    sell at laststop stop//laststop
    exitshort at laststop stop//laststop
    endif
    
    //tailing stop function Donchian base
    
    trailingstart = (CDH[1])//10 trailing will start @trailinstart points profit
    trailingstartV = (CDB[1])//10 trailing will start @trailinstart points profit
    trailingstep = (CDH[1])-((CDB[1])/2) //trailing step to move the "stoploss"
    trailingstepV = (CDB[1])-((CDH[1])/2) //trailing step to move the "stoploss"
     
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
     
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstartV*pipsize THEN
    newSL = tradeprice(1)-trailingstepV*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstepV*pipsize THEN
    newSL = newSL-trailingstepV*pipsize
    ENDIF
    ENDIF
     
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
    
    //************************************************************************
    // Stops et objectifs
    //SET STOP pLOSS 80
    //SET TARGET pPROFIT 100
    #62609 quote
    FREDNC
    Participant
    Senior

    J’ai fait une erreur en écrivant mon post ci-dessus.” sale et saleshort” . En faite j’ai testé en ligne 65 et 69 Sell et exitshort avec “1” j’ai le même code d’erreur. Sans chiffre ou variables c’est le code qui est en en erreur. le ‘perpoint at’ s’affiche en rouge…

    #62623 quote
    Nicolas
    Keymaster
    Master

    Perpoint est spécifique aux comptes “spread betting”, il faudrait essayer en le remplaçant par “contracts”. Et enlever les quantités également comme précédemment évoqué.

    #62660 quote
    FREDNC
    Participant
    Senior

    j’ai essayer “contrats” mais il se met en rouge sans une variable ou un chiffre devant. j’ai chercher dans la liste des fonctions et j’ai trouver “lots” mais on doit aussi donné une valeur.  “COUNTOFPOSITION ” me paraissait prometteur mais dans ce cas là c’est le “at” qui se met en rouge. “All contracts” serais logique mais “All” n’existe pas en tant que fonction et ça nous créer une variable qui du coup deviens un nombre aussi…. Je tourne en rond. j’ai pas mal de stratégies beaucoup plus élaborées en matière de qualité d’entrée en position et gain pur mais j’aime bien le coté sécuritaire de celle-ci. Le conflit de cette stratégie est bien isolé dans ces deux lignes comme tu le disait plus haut. Aurais-tu d’autre suggestion ? Serait-il possible de contourner le problème en changeant  la conception même du stop sur sortie Donchian ? Une pirouette de programmeur  ?

    #63113 quote
    Nicolas
    Keymaster
    Master

    La syntaxe des lignes utilisant “perpoint” devrait être remplacé de cette façon : (à adapter selon la ligne à remplacer bien entendu)

    sell at cDB[1] stop

    Puisque l’on ne peut pas fermer de position partiellement, cette instruction fermera l’ensemble des positions d’achat en une seule fois à l’aide d’un ordre conditionnel au prix de la variable cDB, tel qu’il était 1 période en arrière.

    #63189 quote
    FREDNC
    Participant
    Senior

    Merci Nicolas, je vais essayer un peu plus tard et posterai les résultats.

    #63192 quote
    FREDNC
    Participant
    Senior

    J’ai modifier comme si dessous, j’ai aussi rajouté un SL à 100 Pips pour fixer une limite basse en plus. Ca fonction bien, vois -tu des modifications ou améliorations à y apporter ?

    //stop loss Donchian
    DC=80//80
    //POSITIONSIZE=1
    CDH= Highest[DC](high)
    CDB=Lowest[DC](low)
    if longonmarket then
    //sell positionsize perpoint at cDB[1] stop
    laststop = cDB[1]
    endif
    if shortonmarket then
    //exitshort positionsize perpoint at cDH[1] stop
    laststop = cDH[1]
    endif
    if onmarket then
    sell at laststop stop
    exitshort at laststop stop
    endif
    
    //tailing stop function Donchian base
    
    trailingstart = (CDH[1])//10 trailing will start @trailinstart points profit
    trailingstartV = (CDB[1])//10 trailing will start @trailinstart points profit
    trailingstep = (CDH[1])-((CDB[1])/2) //trailing step to move the "stoploss"
    trailingstepV = (CDB[1])-((CDH[1])/2) //trailing step to move the "stoploss"
     
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
     
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstartV*pipsize THEN
    newSL = tradeprice(1)-trailingstepV*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstepV*pipsize THEN
    newSL = newSL-trailingstepV*pipsize
    ENDIF
    ENDIF
     
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
    
    //************************************************************************
    // Stops et objectifs
    SET STOP pLOSS 100
Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.

Stop Donchian et TP trailer


Support ProOrder

New Reply
Author
author-avatar
FREDNC @frednc Participant
Summary

This topic contains 10 replies,
has 3 voices, and was last updated by FREDNC
7 years, 11 months ago.

Topic Details
Forum: Support ProOrder
Language: French
Started: 02/13/2018
Status: Active
Attachments: No files
Logo Logo
Loading...