Mettre un stop loss a differents niveaux de prix

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #200293 quote
    Prestige-trade
    Participant
    New

    Bonjour,

    Je rencontre un souci pour la mise en place du stop loss, je voudrai que celui-ci évolue et se replace quand un niveau de profit est atteint, toutefois avec le code que j’ai écris il ne se passe rien (il ne sort jamais du marché…) pouvez vous m’aider?

    Merci

    Defparam CumulateOrders=False
    
    MM = Average[20]
    
    // Conditions pour ouvrir une position acheteuse
    IF CLOSE < MM THEN
    BUY 1 CONTRACTS AT MARKET
    SET STOP LOSS 50
    ENDIF
    IF close > (TRADEPRICE+100) then
    SET STOP LOSS (TRADEPRICE+50)
    ENDIF
    IF close > (POSITIONPRICE+200) then
    SET STOP LOSS (POSITIONPRICE+150)
    ENDIF
    
    
    IF STRATEGYPROFIT < -1000 THEN
    QUIT
    ENDIF
    #200299 quote
    JC_Bywan
    Moderator
    Master

    Bonjour,

    Je déplace le sujet du forum ProBuilder (pour indicateurs) au forum ProOrder (stratégies auto et backtests).

    Si la ligne 8 utilise correctement set stop loss avec une distance plutôt qu’un niveau de prix, ce n’est pas le cas des lignes 11 et 14. Si on veut exprimer un niveau de prix plutôt qu’une distance, on peut utiliser par exemple l’instruction set stop price

    set stop loss https://www.prorealcode.com/documentation/ploss/

    set stop price https://www.prorealcode.com/documentation/price/

    #200308 quote
    Prestige-trade
    Participant
    New

    Merci du coup en suivant cela j’ai écris ainsi mais ça ne marche toujours pas ( le stop price n’intervient jamais)?

    BUY 1 CONTRACTS AT MARKET
    SET STOP LOSS 50
    ENDIF
    
    IF close > (TRADEPRICE+100) then
    SET STOP PRICE (TRADEPRICE+50)
    ENDIF
    IF close > (POSITIONPRICE+200) then
    SET STOP PRICE (TRADEPRICE+50)
    ENDIF
    #200342 quote
    Nicolas
    Keymaster
    Master

    Est-ce que la valeur du point est de 1 ? (POINTSIZE), quel est l’instrument ?

    #200361 quote
    Prestige-trade
    Participant
    New

    La valeur du point est de 5 ( Mini FTSE)  en fait je voudrai  que le stop loss a 50 (10point) soit pris a l’achat et que ensuite si le prix augmente de 100 (20points) alors le stop loss soit déplacé a + 10 points par rapport au prix de l’achat et ainsi de suite… mais du coup dois-je plutôt utiliser POSITONPRICE plutôt que TRADEPRICE ou faire autrement? merci beaucoup

    #200377 quote
    Nicolas
    Keymaster
    Master

    Désolé je voulais dire la taille du point (POINTSIZE et non POINTVALUE).

    Bref, si tu veux 20 points alors utilise cette formulation:

    IF close > (TRADEPRICE+20*pointsize) then
     SET STOP PRICE (TRADEPRICE+10*pointsize)
    ENDIF
    #200378 quote
    Nicolas
    Keymaster
    Master

    D’ailleurs ton stoploss devrait être :

    SET STOP PLOSS 10 //10 points
    #200389 quote
    Prestige-trade
    Participant
    New

    Super merci

    #204892 quote
    Prestige-trade
    Participant
    New

    Bonjour,

    Je bloque toujours sur la mise en place d’un stop loss qui changerai suite a l’évolution du prix, en fait celui-ci n’exécute que la dernière commande de stop ptrailing 100 et si je l’enlève il n’éxecute que le stop a (tradeprice+50)…  Pouvez vous m’aider?

    ST = Supertrend[3,30]
     
    IF Not onmarket and CLOSE crosses over ST  and CLOSE > OPEN THEN
    BUY 1 SHARE AT MARKET
    set stop loss 200
    Endif
    
    if LOngonmarket and Close > (tradeprice+75*pointsize) then
    set stop loss 0
    set stop price (Tradeprice+50)
    
    endif
    
    if LOngonmarket and Close > (tradeprice+180*pointsize) then
    set stop price 0
    set stop price (Tradeprice+90*pointsize)
    endif
    
    if LOngonmarket and Close > (tradeprice+250*pointsize) then
    set stop price 0
    set stop price (Tradeprice+160*pointsize)
    endif
    
    if LOngonmarket and Close > (tradeprice+300*pointsize) then
    set stop price 0
    set stop ptrailing 100
    endif
    
    #204919 quote
    Ezel
    Participant
    New

    piuf, tu te complique la vie pour rien,

    garde ton set stoploss x

    et tu rajoutes :

    TGL0 = x (nb de point ou le Trailing Stop pour un achat commence)
    TGS0 = x (nb de point ou le Trailing Stop pour une vente commence)
    
    IF not onmarket THEN
    MINPRICE = close
    MAXPRICE = 0
    PRICEXIT = 0
    ENDIF
    
    IF longonmarket THEN
    MAXPRICE = MAX(MAXPRICE,close)
    IF MAXPRICE - tradeprice(1) >= TGL0 * pointsize THEN
    PRICEXIT = MAXPRICE - TGL0 * pointsize
    ENDIF
    ENDIF
    
    IF shortonmarket then
    MINPRICE = MIN(MINPRICE,close)
    IF tradeprice(1) - MINPRICE >= TGS0 * pointsize THEN
    PRICEEXIT = MINPRICE + TGS0 * pointsize
    ENDIF
    ENDIF
    
    IF onmarket and PRICEXIT>0 THEN
    SELL at PRICEXIT STOP
    ENDIF
    Nicolas thanked this post
    #205022 quote
    Prestige-trade
    Participant
    New

    Bonjour, merci de votre aide, du  coup j’ai modifié en mettant TGLO et TGSO a 300 (donc le stop suiveur devrait commencer a +300 et avant il devrait y avoir des “paliers” mais de combien? )  et en fait sur le backtest il vend un lot mais ne sort jamais… j’ai du faire une erreur?

    Defparam CumulateOrders=False

    ST = Supertrend[3,30]

    TGL0 = 300 //(nb de point ou le Trailing Stop pour un achat commence)
    TGS0 = 300 //(nb de point ou le Trailing Stop pour une vente commence)

    IF Not onmarket and CLOSE crosses over ST and CLOSE > OPEN THEN
    BUY 1 SHARE AT MARKET
    set stop loss 200
    Endif

    IF not onmarket THEN
    MINPRICE = close
    MAXPRICE = 0
    PRICEXIT = 0
    ENDIF

    IF longonmarket THEN
    MAXPRICE = MAX(MAXPRICE,close)
    IF MAXPRICE – tradeprice(1) >= TGL0 * pointsize THEN
    PRICEXIT = MAXPRICE – TGL0 * pointsize
    ENDIF
    ENDIF

    IF Not onmarket and CLOSE crosses under ST and CLOSE < OPEN THEN
    Sellshort 1 SHARE AT MARKET
    set stop loss 200
    Endif

    IF shortonmarket then
    MINPRICE = MIN(MINPRICE,close)
    IF tradeprice(1) – MINPRICE >= TGS0 * pointsize THEN
    PRICEEXIT = MINPRICE + TGS0 * pointsize
    ENDIF
    ENDIF

    IF onmarket and PRICEXIT>0 THEN
    SELL at PRICEXIT STOP
    ENDIF

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

Mettre un stop loss a differents niveaux de prix


ProOrder : Trading Automatique & Backtests

New Reply
Author
Summary

This topic contains 10 replies,
has 4 voices, and was last updated by Prestige-trade
3 years, 3 months ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 09/07/2022
Status: Active
Attachments: No files
Logo Logo
Loading...