Mettre SL plus court PUIS Breackeven

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #235969 quote
    teshmi9zteshmi9z
    Participant
    New

    bonjour, j’ai codé un strategie simple pour faire des test ( ZLEMA cross MM)
    mon soucis est que j’aimerais mettre des palier de prix pour proteger mon trade, je mexplique

    Condition achat (ZLEMA 20 cross UP MM50) Target 200  SL 100:

    Si Trade price + 60 point Alors on remonte le SL de 50 pts PUIS

    si Trade price + 120 point Alors Breackeven

    ca ne fonction pas dans mon code j’ai tous essayé mais impossible pour moi.
    Si quelqu’un sais pourquoi seul la première condition marche (SL a 50) ?

    merci d’avance

    defparam CUMULATEORDERS = false
    
    // test de validation du BE avec un simple cross de MM
    mm20 = ZLEMA[20](close) 
    mm50 = average[50]
    
    signalU = mm20 CROSSES OVER mm50
    signalD= mm20 CROSSES UNDER mm50 
    
    if signalU then
    buy 1 contract at market
    SET TARGET pPROFIT 200
    set stop loss 100
    endif
    
    if longonmarket then
    if high-tradeprice >= 60*pointsize then
    set stop loss 50
    slUp=1
    endif
    if high-tradeprice >=120*pointsize THEN 
    set stop BREAKEVEN 
    endif
    if signalD THEN 
    sell at market
    endif
    endif
    #235980 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Bonjour, il a légèrement modifié et ajouté un stoploss variable pour que vous puissiez l'actualiser.

    defparam CUMULATEORDERS = false
    
    // test de validation du BE avec un simple cross de MM
    mm20 = ZLEMA[20](close)
    mm50 = average[50]
    
    signalU = mm20 CROSSES OVER mm50
    signalD= mm20 CROSSES UNDER mm50
    
    if signalU then
    buy 1 contract at market
    SET TARGET pPROFIT 200
    set stop ploss 100
    endif
    
    if longonmarket then
    if not longonmarket[1] then
    stoploss=tradeprice-100*pointsize*pointvalue
    endif
    if high-tradeprice >= 60*pointsize then
    stoploss=tradeprice-50*pointsize*pointvalue
    set stop ploss 50
    slUp=1
    endif
    if high-tradeprice >=120*pointsize*pointvalue THEN
    stoploss=tradeprice
    set stop BREAKEVEN
    endif
    if signalD THEN
    sell at market
    endif
    endif
    
    graphonprice stoploss coloured("red")
    #235994 quote
    teshmi9zteshmi9z
    Participant
    New

    merci de ta réponse, du coup de mon coté j’avais continué a développer un système à 3 postions de réglages:
    1: décalage du SL

    2 et 3 : modification du STOP WIN

    le système me parait fonctionnel

    defparam CUMULATEORDERS = true
    
    // test de validation du BE avec un simple cross de MM
    mm20 = ZLEMA[20](close)
    mm50 = average[50](close)
    //conditions Order
    signalU = mm20 CROSSES OVER mm50
    signalD= mm20 CROSSES UNDER mm50
    ////////// Trade mangement///////////////
    //BUY
    BuyTP1=60   // Target pour monter le SL
    BuySL1=50   // Nouveau SL
    BuyBE1=100   // Seuil BE 1
    BBE1=20       // Trade price + points
    BuyBE2=120   // Seuil BE 2
    BBE2= 60     // trade price + Point
    
    if signalU then
    buy 1 contract at market
    SET TARGET pPROFIT 220
    set stop loss 100
    endif
    
    if signalD then
    sellshort 1 contract at market
    set target profit 200
    set stop loss 80
    endif
    
    //LONG CONDITION
    if not onmarket then
    be=0
    endif
    if longonmarket and close-tradeprice>=BuyBE1 *pointsize then
    be=1
    endif
    if be=1 then
    sell at tradeprice+BBE1*pointsize stop
    endif
    if not onmarket then
    bee=0
    endif
    if longonmarket and close-tradeprice>=BuyBE2*pointsize then
    bee=1
    endif
    if bee=1 then
    sell at tradeprice+BBE2*pointsize stop
    endif
    
    SL1=high-tradeprice >= BuyTP1 *pointsize
    if longonmarket then
    if SL1 then
    set stop loss BuySL1
    endif
    endif
    
    //SHORT
    SellTP1=50   // Target pour descendre le SL
    SELLSL1=50   // Nouveau SL
    
    SellBE1=80   // Seuil BE 1
    SBE1=20     // Trade price + points
    SellBE2=150   // Seuil BE 2
    SBE2= 50     // trade price + Point
    if not onmarket then
    Sbe=0
    endif
    if SHORTONMARKET  and tradeprice-close>=SellBE1 *pointsize then
    Sbe=1
    endif
    if Sbe=1 then
    exitshort at tradeprice-SBE1*pointsize stop
    endif
    if not onmarket then
    Sbee=0
    endif
    if SHORTONMARKET  and tradeprice-close>=SellBE2*pointsize then
    Sbee=1
    endif
    if Sbee=1 then
    exitshort at tradeprice-SBE2*pointsize stop
    endif
    //
    SL2=high-tradeprice <= SellTP1 *pointsize
    if SHORTONMARKET  THEN
    if SL2 then
    set stop loss SELLSL1
    endif
    endif
    
    #236116 quote
    teshmi9zteshmi9z
    Participant
    New

    voici une version ameliorer par Mistral Ia

    defparam CUMULATEORDERS = true
    
    // Calcul des moyennes mobiles
    mm20 = ZLEMA[20](close)
    mm50 = average[50](close)
    
    // Conditions de croisement
    signalU = mm20 CROSSES OVER mm50
    signalD = mm20 CROSSES UNDER mm50
    
    // Paramètres de gestion des trades
    BuyTP1 = 60   // Target pour monter le SL
    BuySL1 = 50   // Nouveau SL
    BuyBE1 = 100  // Seuil BE 1
    BBE1 = 20     // Trade price + points
    BuyBE2 = 120  // Seuil BE 2
    BBE2 = 60     // Trade price + points
    
    SellTP1 = 50  // Target pour descendre le SL
    SELLSL1 = 50  // Nouveau SL
    SellBE1 = 80  // Seuil BE 1
    SBE1 = 20     // Trade price + points
    SellBE2 = 150 // Seuil BE 2
    SBE2 = 50     // Trade price + points
    
    // Entrée en position
    if signalU then
        buy 1 contract at market
        set target profit 220
        set stop loss 100
    endif
    
    if signalD then
        sellshort 1 contract at market
        set target profit 200
        set stop loss 80
    endif
    
    // Gestion des positions longues
    if not onmarket then
        be = 0
        bee = 0
    endif
    
    if longonmarket then
        if close - tradeprice >= BuyBE1 * pointsize then
            be = 1
        endif
        if be = 1 then
            sell at tradeprice + BBE1 * pointsize stop
        endif
    
        if close - tradeprice >= BuyBE2 * pointsize then
            bee = 1
        endif
        if bee = 1 then
            sell at tradeprice + BBE2 * pointsize stop
        endif
    
        if high - tradeprice >= BuyTP1 * pointsize then
            set stop loss BuySL1
        endif
    endif
    
    // Gestion des positions courtes
    if not onmarket then
        Sbe = 0
        Sbee = 0
    endif
    
    if SHORTONMARKET then
        if tradeprice - close >= SellBE1 * pointsize then
            Sbe = 1
        endif
        if Sbe = 1 then
            exitshort at tradeprice - SBE1 * pointsize stop
        endif
    
        if tradeprice - close >= SellBE2 * pointsize then
            Sbee = 1
        endif
        if Sbee = 1 then
            exitshort at tradeprice - SBE2 * pointsize stop
        endif
    
        if tradeprice - high >= SellTP1 * pointsize then
            set stop loss SELLSL1
        endif
    endif
    Iván González thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Mettre SL plus court PUIS Breackeven


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
teshmi9z @teshmi9z Participant
Summary

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

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 07/31/2024
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...