Optimisation code/strat de ma stratégie sur le DAX en UT 4 minutes

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #145511 quote
    Yvan63
    Participant
    Senior

    Bonjour,

    Je joins ici un petit code polyvalent en UT 4 minutes (DAX30 uniquement sur CFD), l’idée et de prendre des positions en exploitant une MME100 et une stoc.
    J’utilise un stop suiveur pour les longs et un TP fixe pour les shorts.
    Cet algo a 62,66% de trade gagnants et un ration gains/pertes de 1,39% aujourd’hui.
    Je ne l’ai pas optimisé avec les outils de PRT car je le veux le plus polyvalent possible, pour moi le challenge était de le faire traverser le mini crash de mars pour éprouver son comportement.
    C’est pas trop mal mais je cherche des idées pour l’optimiser, peut-être pas dans l’idée de prendre plus de position mais plutôt supprimer des trades perdants (sans optimisation PRT), plutôt optimisation sur l’ajout de filtres etc…
    Donc c’est une première, je pose le code ici et attends vos lumières 🙂
    Autre chose: je souhaiterais pouvoir effectuer des statistiques sur les résultats de mes backtests, seulement comment peut-on exporter les datas du tableau de résultats ? (je suis sous PRT 10.3)
    Par exemple, connaitre à quelles heures cet algo perd ou gagne le plus souvent m’intéresse…

     

    @+

     

    // UT = 4 minutes
    // Versions 1.1 mercredi 16/09/20 à 21:11
    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
    //Annule tous les ordres en attente et ferme toutes les positions à 0:00, puis empêche toute création d'ordre avant l'heure "FLATBEFORE".
    DEFPARAM FLATBEFORE = 081500
    ////////// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"
    DEFPARAM FLATAFTER = 213000
    
    DEFPARAM Preloadbars = 1000
    
    Long1On = 1 // pas très efficace ?
    Long2ON = 1
    ShortON = 1 // Short activé ?
    ONCE TSL = 1  // Use TSL?
    
    // Evite l'ouverture de WS
    Temps1 = time >= 151500 and time < 160000
    
    MME100 = Average[100,1](close)
    sto = Stochastic[14,3](close)
    //signal = average[5](sto)
     
    If Long1On then
    //// LONG-1 //// Une bougie de part et autre de la EMA100
    
    c1 = high > MME100 and close > open
     
    c2 = close - open > 12// bougie de x point minimum
     
    c3 = high[1] < MME100 and open[1] < close[1] // bougie précédente verte également et inférieure à MME100
     
    c4 = sto < 60 // filtrage par STO
     
    c5 = 1
    
    C13 = c1 and c2 and c3 and c4 and c5 and not Temps1 and NOT LongOnMarket
     
    IF C13  THEN
    BUY 1 CONTRACT AT MARKET
    Set Target pprofit 0
    SET STOP LOSS (close-low) // SL sous le plus bas de la bougie précédente
    
    ENDIF
    
    Endif
    
    If Long2On then
    
    //// LONG-2 //// Une bougie rebondit sur la MME100
    
    d1 = close > open
    
    d2 = open > MME100 and close > MME100
    
    d3 = open[1] > MME100 and close[1] > MME100
    
    d4 = low[1] < MME100 and low < MME100
    
    d5 = close[1] > open[1]
    
    D13 = d1 and d2 and d3 and d4 and d5 and not Temps1 and NOT LongOnMarket
    
    IF D13  THEN
    BUY 1 CONTRACT AT MARKET
    Set Target pprofit 0
    If (close-low) < 11 then
    SET STOP LOSS 11 // Stop LOSS passe partout si bougie trop petite
    Else
    SET STOP LOSS (close-low) // SL sous le plus bas de la bougie précédente
    Endif
    
    ENDIF
    
    Endif
    
    IF ShortON then
    ///// SHORT ////---------------------------------------------------------------------
    c6 = close < MME100 and close < open
     
    c7 = open - close > 14// bougie de x point minimum
     
    c8 = low[1] > MME100 and open[1] > close[1]
     
    c9 = sto > 19 // filtrage par STO
     
    c10 = 1
    
    C14 = c6 and c7 and c8 and c9 and c10 and not Temps1 and NOT ShortOnMarket
    
    IF C14  THEN
    Sellshort 1 CONTRACT AT MARKET
    SET STOP LOSS (high-close) // SL sur le plus haut de la bougie précédente
    SET Target Pprofit 19 // Pas de stop suiveur car mouvement de baisse trop rapide
    ENDIF
    
    EndIf
    
    // *****************************
    IF TSL = 1 THEN
    
    //trailing stop function
    trailingstart = 8 //trailing will start @trailinstart points profit
    trailingstep = 6 // 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 THEN
    newSL = tradeprice(1)+trailingstep
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep THEN
    newSL = newSL+trailingstep
    ENDIF
    Sell at newSL stop // Place un ordre de vente stop en guise de seuil de stopsuiveur
    //graph newSL coloured (0,255,255) as "newSL"
    ENDIF
    
    
    ENDIF
    
    #145517 quote
    Yvan63
    Participant
    Senior

    Edit, je n’ai pas mis la dernière version du code, la voici:

    // Versions 1.2 vendredi 18/09/20 à 22:38
    
    /////////////////////////////////////////////////////////////////////////////////
    
    /////////////////////////////////////////////////////////////////////////////////
    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
    //Annule tous les ordres en attente et ferme toutes les positions à 0:00, puis empêche toute création d'ordre avant l'heure "FLATBEFORE".
    DEFPARAM FLATBEFORE = 081500
    ////////// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"
    DEFPARAM FLATAFTER = 213000
    
    DEFPARAM Preloadbars = 1000
    
    Long1On = 1 // pas très efficace ?
    Long2ON = 1
    ShortON = 1 // Short activé ?
    ONCE TSL = 1  // Use TSL?
    
    // Evite l'ouverture de WS
    //Temps1 = time >= 151500 and time < 160000
    Temps1 = 0 // neutralise ce filtre
    
    MME100 = Average[100,1](close)
    sto = Stochastic[14,3](close)
    //signal = average[5](sto)
     
    If Long1On then
    //// LONG-1 //// Une bougie de part et autre de la EMA100
    
    c1 = high > MME100 and close > open
     
    c2 = close - open > 12// bougie de x point minimum
     
    c3 = high[1] < MME100 and open[1] < close[1] // bougie précédente verte également et inférieure à MME100
     
    c4 = sto < 60 // filtrage par STO
     
    c5 = 1
    
    C13 = c1 and c2 and c3 and c4 and c5 and not Temps1 and NOT LongOnMarket
     
    IF C13  THEN
    BUY 1 CONTRACT AT MARKET
    Set Target pprofit 0
    If (close-low) < 11 then
    SET STOP LOSS 11 // Stop LOSS passe partout si bougie trop petite
    Else
    SET STOP LOSS (close-low) // SL sous le plus bas de la bougie précédente
    Endif
    
    ENDIF
    
    Endif
    
    If Long2On then
    
    //// LONG-2 //// Une bougie rebondit sur la MME100
    
    d1 = close > open // bougie verte
    
    d2 = open > MME100 and close > MME100
    
    d3 = open[1] > MME100 and close[1] > MME100
    
    d4 = low[1] < MME100 and low < MME100
    
    d5 = close[1] > open[1]
    
    D13 = d1 and d2 and d3 and d4 and d5 and not Temps1 and NOT LongOnMarket
    
    IF D13  THEN
    BUY 1 CONTRACT AT MARKET
    Set Target pprofit 0
    If (close-low) < 11 then
    SET STOP LOSS 11 // Stop LOSS passe partout si bougie trop petite
    Else
    SET STOP LOSS (close-low) // SL sous le plus bas de la bougie précédente
    Endif
    
    ENDIF
    
    Endif
    
    IF ShortON then
    ///// SHORT ////---------------------------------------------------------------------
    c6 = close < MME100 and close < open
     
    c7 = open - close > 14// bougie de x point minimum
     
    c8 = low[1] > MME100 and open[1] > close[1]
     
    c9 = sto > 19 // filtrage par STO
     
    c10 = 1
    
    C14 = c6 and c7 and c8 and c9 and c10 and not Temps1 and NOT ShortOnMarket
    
    IF C14  THEN
    Sellshort 1 CONTRACT AT MARKET
    SET STOP LOSS (high-close) // SL sur le plus haut de la bougie précédente
    SET Target Pprofit 19 // Pas de stop suiveur car mouvement de baisse trop rapide
    ENDIF
    
    EndIf
    
    // *****************************
    IF TSL = 1 THEN
    
    //trailing stop function
    trailingstart = 8 //trailing will start @trailinstart points profit
    trailingstep = 6 // 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 THEN
    newSL = tradeprice(1)+trailingstep
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep THEN
    newSL = newSL+trailingstep
    ENDIF
    Sell at newSL stop // Place un ordre de vente stop en guise de seuil de stopsuiveur
    //graph newSL coloured (0,255,255) as "newSL"
    ENDIF
    
    
    ENDIF
    
    #145539 quote
    Yvan63
    Participant
    Senior

    Ajout d’un filtre de volatilité

     

    // UT = 4 minutes
    // Versions 1.3
    
    /////////////////////////////////////////////////////////////////////////////////
    
    /////////////////////////////////////////////////////////////////////////////////
    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
    //Annule tous les ordres en attente et ferme toutes les positions à 0:00, puis empêche toute création d'ordre avant l'heure "FLATBEFORE".
    DEFPARAM FLATBEFORE = 081500
    ////////// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"
    DEFPARAM FLATAFTER = 213000
    
    DEFPARAM Preloadbars = 1000
    
    Long1On = 1 // pas très efficace ?
    Long2ON = 1
    ShortON = 1 // Short activé ?
    ONCE TSL = 1  // Use TSL?
    
    // Evite l'ouverture de WS
    //Temps1 = time >= 151500 and time < 160000
    Temps1 = 0 // neutralise ce filtre
    
    MME100 = Average[100,1](close)
    sto = Stochastic[14,3](close)
    ATR = AverageTrueRange[10](close)
    //signal = average[5](sto)
     
    If Long1On then
    //// LONG-1 //// Une bougie de part et autre de la EMA100
    
    c1 = high > MME100 and close > open
     
    c2 = close - open > 12// bougie de x point minimum
     
    c3 = high[1] < MME100 and open[1] < close[1] // bougie précédente verte également et inférieure à MME100
     
    c4 = sto < 60 // filtrage par STO
     
    c5 = ATR < 16
    
    C13 = c1 and c2 and c3 and c4 and c5 and not Temps1 and NOT LongOnMarket
     
    IF C13  THEN
    BUY 1 CONTRACT AT MARKET
    Set Target pprofit 0
    If (close-low) < 11 then
    SET STOP LOSS 11 // Stop LOSS passe partout si bougie trop petite
    Else
    SET STOP LOSS (close-low) // SL sous le plus bas de la bougie précédente
    Endif
    
    ENDIF
    
    Endif
    
    If Long2On then
    
    //// LONG-2 //// Une bougie rebondit sur la MME100
    
    d1 = close > open // bougie verte
    
    d2 = open > MME100 and close > MME100
    
    d3 = open[1] > MME100 and close[1] > MME100
    
    d4 = low[1] < MME100 and low < MME100
    
    d5 = close[1] > open[1] and close[1] - open[1] > 1
    
    d6 = ATR < 16
    
    D13 = d1 and d2 and d3 and d4 and d5 and d6 and not Temps1 and NOT LongOnMarket
    
    IF D13  THEN
    BUY 1 CONTRACT AT MARKET
    Set Target pprofit 0
    If (close-low) < 11 then
    SET STOP LOSS 11 // Stop LOSS passe partout si bougie trop petite
    Else
    SET STOP LOSS (close-low) // SL sous le plus bas de la bougie précédente
    Endif
    
    ENDIF
    
    Endif
    
    IF ShortON then
    ///// SHORT ////---------------------------------------------------------------------
    c6 = close < MME100 and close < open
     
    c7 = open - close > 14// bougie de x point minimum
     
    c8 = low[1] > MME100 and open[1] > close[1]
     
    c9 = sto > 19 // filtrage par STO
     
    c10 = 1
    
    C14 = c6 and c7 and c8 and c9 and c10 and not Temps1 and NOT ShortOnMarket
    
    IF C14  THEN
    Sellshort 1 CONTRACT AT MARKET
    SET STOP LOSS (high-close) // SL sur le plus haut de la bougie précédente
    SET Target Pprofit 19 // Pas de stop suiveur car mouvement de baisse trop rapide
    ENDIF
    
    EndIf
    
    // *****************************
    IF TSL = 1 THEN
    
    //trailing stop function
    trailingstart = 8 //trailing will start @trailinstart points profit
    trailingstep = 6 // 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 THEN
    newSL = tradeprice(1)+trailingstep
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep THEN
    newSL = newSL+trailingstep
    ENDIF
    Sell at newSL stop // Place un ordre de vente stop en guise de seuil de stopsuiveur
    //graph newSL coloured (0,255,255) as "newSL"
    ENDIF
    
    //manage short positions
    //IF SHORTONMARKET THEN
    ////first move (breakeven)
    //IF newSL=0 AND tradeprice(1)-close>=trailingstart THEN
    //newSL = tradeprice(1)-trailingstep
    //ENDIF
    ////next moves
    //IF newSL>0 AND newSL-close>=trailingstep THEN
    //newSL = newSL-trailingstep
    //ENDIF
    //Exitshort at newSL stop // Place un ordre d'achat stop en guise de seuil de stopsuiveur
    //graph newSL coloured (255,255,255) as "newSL SHORT"
    //
    //ENDIF
    
    ENDIF
    
    #145610 quote
    Nicolas
    Keymaster
    Master

    Merci pour le partage de ta stratégie, ci-joint le backtest avec un spread de 1.5 points sur les dernières 200.000 unités en timeframe 4-minutes.

    dax-backtests-200000-unites.png dax-backtests-200000-unites.png
    #145746 quote
    Yvan63
    Participant
    Senior

    J’avais mieux que ça, tout était activé ? (Long1, Long2 et ShortON) ?
    Bref, avec spread à 1,2 et sur 200000 units, tout activé mais sans le filtrage sur les plus BAS/plus haut J et mensuel que je n’arrive pas encore à coder 😉

    // UT = 4 minutes, DAX30 uniquement
    // Versions 1.3 du 27/09/20
    
    /////////////////////////////////////////////////////////////////////////////////
    
    /////////////////////////////////////////////////////////////////////////////////
    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
    //Annule tous les ordres en attente et ferme toutes les positions à 0:00, puis empêche toute création d'ordre avant l'heure "FLATBEFORE".
    DEFPARAM FLATBEFORE = 081000
    ////////// Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"
    DEFPARAM FLATAFTER = 213000
    
    DEFPARAM Preloadbars = 1000
    
    Long1On = 1 // pas très efficace ?
    Long2ON = 1
    ShortON = 1 // Short activé ?
    ONCE TSL = 1  // Use TSL?
    
    // Evite l'ouverture de WS
    //Temps1 = time >= 151500 and time < 160000
    Temps1 = 0 // neutralise ce filtre
    
    MME110 = Average[110,1](close)
    sto = Stochastic[10,3](close)
    ATR = AverageTrueRange[10](close)
     
    
    If Long1On then
    //// LONG-1 //// Une bougie de part et autre de la EMA100
    
    c1 = high > MME110 and close > open
     
    c2 = close - open > 12// bougie de x point minimum
     
    c3 = high[1] < MME110 and open[1] < close[1] // bougie précédente verte également et inférieure à MME110
     
    c4 = sto < 60 // filtrage par STO
     
    c5 = ATR < 15
    
    Ctotal = c1 and c2 and c3 and c4 and c5 and not Temps1 and NOT LongOnMarket
     
    IF Ctotal  THEN
    BUY 1 CONTRACT AT MARKET
    Set Target pprofit 0
    If (close-low) < 11 then
    SET STOP LOSS 11 // Stop LOSS passe partout si bougie trop petite
    Else
    SET STOP LOSS (close-low) // SL sous le plus bas de la bougie précédente
    Endif
    
    ENDIF
    
    Endif
    
    If Long2On then
    
    //// LONG-2 //// Une bougie rebondit sur la MME110
    
    d1 = close > open // bougie verte
    
    d2 = open > MME110 and close > MME110
    
    d3 = open[1] > MME110 and close[1] > MME110
    
    d4 = low[1] < MME110 and low < MME110
    
    d5 = close[1] > open[1] and close[1] - open[1] > 1
    
    d6 = ATR < 16
    
    Dtotal = d1 and d2 and d3 and d4 and d5 and d6 and not Temps1 and NOT LongOnMarket
    
    IF Dtotal  THEN
    BUY 1 CONTRACT AT MARKET
    Set Target pprofit 0
    If (close-low) < 11 then
    SET STOP LOSS 11 // Stop LOSS passe partout si bougie trop petite
    Else
    SET STOP LOSS (close-low) // SL sous le plus bas de la bougie précédente
    Endif
    
    ENDIF
    
    Endif
    
    IF ShortON then
    ///// SHORT ////---------------------------------------------------------------------
    
    e4 = close > DLow(1)
    e4 = 1
    
    e5 = close < DHigh(1)
    e5 = 1
    e6 = close < MME110 and close < open
     
    e7 = open - close > 14// bougie de x point minimum
     
    e8 = low[1] > MME110 and open[1] > close[1]
     
    e9 = sto > 21 // filtrage par STO
     
    e10 = (close-low)< (open-close)*0.9 // la mèche ne doit pas éxcéder 75% du corps de la bougie
    
    Etotal = e4 and e5 and e6 and e7 and e8 and e9 and e10 and not Temps1 and NOT ShortOnMarket
    
    IF Etotal  THEN
    Sellshort 1 CONTRACT AT MARKET
    SET STOP LOSS (high-close) // SL sur le plus haut de la bougie de décision
    SET Target Pprofit 19 // Pas de stop suiveur car mouvement de baisse trop rapide
    ENDIF
    
    EndIf
    
    // *****************************
    IF TSL = 1 THEN
    
    //trailing stop function
    trailingstart = 8 //trailing will start @trailinstart points profit
    trailingstep = 6 // 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 THEN
    newSL = tradeprice(1)+trailingstep
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep THEN
    newSL = newSL+trailingstep
    ENDIF
    Sell at newSL stop // Place un ordre de vente stop en guise de seuil de stopsuiveur
    //graph newSL coloured (0,255,255) as "newSL"
    ENDIF
    
    //manage short positions
    //IF SHORTONMARKET THEN
    ////first move (breakeven)
    //IF newSL=0 AND tradeprice(1)-close>=trailingstart THEN
    //newSL = tradeprice(1)-trailingstep
    //ENDIF
    ////next moves
    //IF newSL>0 AND newSL-close>=trailingstep THEN
    //newSL = newSL-trailingstep
    //ENDIF
    //Exitshort at newSL stop // Place un ordre d'achat stop en guise de seuil de stopsuiveur
    //graph newSL coloured (255,255,255) as "newSL SHORT"
    //
    //ENDIF
    
    ENDIF
    
    Strat-1.3-2.png Strat-1.3-2.png Strat-1.3-1.png Strat-1.3-1.png
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Optimisation code/strat de ma stratégie sur le DAX en UT 4 minutes


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
Yvan63 @yvan63 Participant
Summary

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

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 09/27/2020
Status: Active
Attachments: 3 files
Logo Logo
Loading...