Stop position LONG ou COURT après x barres

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #148311 quote
    Fab28
    Participant
    Senior

    Bonjour

    Dans l’élaboration d’une stratégie automatique en 30 secondes sur le Dax, j’ai mis en place le stop suivant pour sortir du marché.

    SET STOP pLOSS 19
    
    //************************************************************************
    //trailing stop function
    trailingstart = 7 //trailing will start @trailinstart points profit
    trailingstep = 7 //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
    
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = newSL-trailingstep*pipsize
    ENDIF
    ENDIF
    
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF

    Je souhaiterai ajouter une condition pour clôturer mes positions

    Si je suis toujours long ou court après 50 barres, je coupe mes positions.

    Pouvez vous m’aider ?

     

    Autre question, auriez vous un autre stop plus adapté pour une stratégie de scalping sur le DAX ?

    J’ai beau chercher sur le forum.

    Malheureusement, je ne comprends pas les nombreux codes proposés et je m’y perds

    Merci d’avance pour votre aide.

    #148328 quote
    fifi743
    Participant
    Master

    Bonjour,

    pour les x bars voici le code

    if barindex-tradeindex>50 then
    sell at market
    exitshort at market
    endif
    #148355 quote
    robertogozzi
    Moderator
    Master

    Si vous mettez à l’échelle un TF court, d’une minute ou moins et que vous avez un TP de 10 pips, vous pouvez écrire un code qui vous laissera sortir lorsque vous aurez gagné au moins 2/3 du bénéfice:

    Pips = 10 * PipSize
    If LongOnMarket and ((close - TradePrice) >= (Pips * 2 / 3))) Then
       Sell at Market
    Endif
    If ShortOnMarket and ((TradePrice -  close) >= (Pips * 2 / 3))) Then
       Exitshort at Market
    Endif

    cela vous permettra de gagner 10 pips si un pic est suffisamment important, sinon encaisser un profit inférieur, au cas où le prix reviendrait.

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

Stop position LONG ou COURT après x barres


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
Fab28 @fab28 Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by robertogozzi
5 years, 4 months ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 10/24/2020
Status: Active
Attachments: No files
Logo Logo
Loading...