Problème fonction trailing stop

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #49841 quote
    Phil4910
    Participant
    Average

    Bonjour Nicolas,

    J’ai utilisé dans un probacktest ton code “Trailing stop code function” auquel j’ai ajouté une “Safety exit”

    Le problème est que cette “Safety exit” ne fonctionne pas (mal placée?), de sorte que ma plus grosse perte dépasse largement mon plus gros gain 🙁 même si le système reste rentable (cfr image jointe).

    Je pourrais résoudre ce problème en mettant un stop loss fixe (à 20) mais alors mon % de positions gagnantes diminue.

    Autre chose qui est bizarre : aucune de mes positions ne se termine au breakeven -> ?

    Une idée?

    Phil4910.

    IF NOT ONMARKET  and Condition1 and Condition2 and Condition3 THEN
    BUY 5 CONTRACT at open stop
    // Safety exit
    IF LONGONMARKET AND Condition4 THEN
    sell at close stop
    ENDIF
    endif
     
    //trailing stop function
    trailingstart = 10 //trailing will start @trailinstart points profit
    trailingstep = 3 //trailing step to move the "stoploss"
     
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
     
    //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
     
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    Endif
    Sans-titre-2.png Sans-titre-2.png
    #49869 quote
    Nicolas
    Keymaster
    Master

    Ton ‘safety exit’ à la ligne 5, tu souhaites sortir de position immédiatement ? Sinon, mettre un ordre stop à l’endroit précis ou tu trouves au moment où le code est lu, c’est à dire au Close, est une mauvaise idée. En réel, l’ordre sera rejetée dut à la distance minimale à respecter pour poser ce type d’ordre.

    Pour mémoire, cette fonction de trailing stop n’inclut pas de stoploss avant que celui-ci ne s’enclenche, donc placer un SET STOP PLOSS n’est pas une mauvaise idée, quoiqu’il arrive il en faudra un pour un compte à risque limité.

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

Problème fonction trailing stop


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
Phil4910 @phil4910 Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Nicolas
8 years, 4 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 10/18/2017
Status: Active
Attachments: 1 files
Logo Logo
Loading...