Stratégie pattern de retournement

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #250344 quote
    Cédric Froidefond
    Participant
    Junior

    Bonjours

    J’ai codé la stratégie, mai vue que c la première je pense avoir oublié des trucs, et si possible de backtest la stratégie pour voir si elle et rentable sur le long terme, vous pouvez apporter des modifications.

    Sur le Dax en 1 min.

    17569786074294004683199777342326.jpg 17569786074294004683199777342326.jpg
    #250349 quote
    GraHal
    Participant
    Master

    Votre code est impossible à voir car si petit, mais il n’est pas non plus convivial dans un .jpg.

    Postez votre code par copier-coller en utilisant le bouton bleu – Insérer le code PRT – sur la flèche verte ci-jointe et je le testerai sur ma plateforme pour vous.

    E4i95BlWT2.png E4i95BlWT2.png
    #250351 quote
    Cédric Froidefond
    Participant
    Junior

    // ============================
    // STRATÉGIE PATTERN RETOURNEMENT DAX
    // ============================

    DEFPARAM CumulateOrders = False
    DEFPARAM PreLoadBars = 500

    // — Heikin Ashi —
    haClose = (open + high + low + close) / 4
    haOpen = (haOpen[1] + haClose[1]) / 2
    haHigh = max(high, haOpen, haClose)
    haLow = min(low, haOpen, haClose)

    // — Détection du pattern —
    // Impulsion
    impulseUp = haClose > haOpen AND haClose > haHigh[1]
    impulseDown = haClose < haOpen AND haClose < haLow[1] // Hésitation hesitation = (haHigh - haClose > 1 AND haClose – haLow > 1)

    // Validation du retournement
    reversalUp = impulseDown[1] AND hesitation AND haClose > haHigh[1]
    reversalDown = impulseUp[1] AND hesitation AND haClose < haLow[1] // ============================ // FILTRE JOUR & HEURE // ============================ isTradingDay = dayofweek >= 1 AND dayofweek <= 5 isTradingHour = time >= 083000 AND time < 200000 // ============================ // CONDITIONS D’ENTRÉE // ============================ // Entrée en long IF isTradingDay AND isTradingHour AND reversalUp THEN BUY 1 CONTRACT AT MARKET stopLevel = lowest[5](low) // stop initial SET STOP pLOSS (close - stopLevel) * pipsize ENDIF // Entrée en short IF isTradingDay AND isTradingHour AND reversalDown THEN SELLSHORT 1 CONTRACT AT MARKET stopLevel = highest[5](high) SET STOP pLOSS (stopLevel - close) * pipsize ENDIF // ============================ // STOP SUIVEUR DYNAMIQUE // ============================ IF longonmarket THEN profitPoints = close - tradeprice(1) // Activation du stop suiveur à +8 points IF profitPoints >= 8 THEN
    newStop = tradeprice(1) + 2 // +2 points au-dessus du prix d’entrée
    step = FLOOR((profitPoints – 8) / 4)
    newStop = MAX(newStop, tradeprice(1) + step * 4 + 2)
    SET STOP ploss (tradeprice(1) – newStop) * pipsize
    ENDIF
    ENDIF

    IF shortonmarket THEN
    profitPoints = tradeprice(1) – close

    IF profitPoints >= 8 THEN
    newStop = tradeprice(1) – 2 // -2 points sous le prix d’entrée
    step = FLOOR((profitPoints – 8) / 4)
    newStop = MIN(newStop, tradeprice(1) – step * 4 – 2)
    SET STOP ploss (newStop – tradeprice(1)) * pipsize
    ENDIF
    ENDIF

    // ============================
    // CLÔTURE FORCÉE À 20h00
    // ============================
    IF time >= 200000 THEN
    IF longonmarket THEN
    SELL AT MARKET
    ENDIF
    IF shortonmarket THEN
    EXITSHORT AT MARKET
    ENDIF
    ENDIF

    #250353 quote
    GraHal
    Participant
    Master
    // ==============================
    // DAX REVERSAL PATTERN STRATEGY
    // ================================
    
    DEFPARAM CumulateOrders = False
    DEFPARAM PreLoadBars = 500
    
    // — Heikin Ashi —
    haClose = (open + high + low + close) / 4
    haOpen = (haOpen[1] + haClose[1]) / 2
    haHigh = max(high, max(haOpen, haClose))
    haLow = min(low, max(haOpen, haClose))
    
    // — Détection du pattern —
    // Impulsion
    impulseUp = haClose > haOpen AND haClose > haHigh[1]
    impulseDown = haClose < haOpen AND haClose < haLow[1] // Hésitation
    hesitation = (haHigh - haClose > 1 AND haClose - haLow > 1)
    
    // Validation du retournement
    reversalUp = impulseDown[1] AND hesitation AND haClose > haHigh[1]
    reversalDown = impulseUp[1] AND hesitation AND haClose < haLow[1] // ============================ // FILTRE JOUR & HEURE // ============================
    isTradingDay = dayofweek >= 1 AND dayofweek <= 5
    isTradingHour = time >= 083000 AND time < 200000 // ============================ // CONDITIONS D’ENTRÉE // ============================ // Entrée en long
    IF isTradingDay AND isTradingHour AND reversalUp THEN
    BUY 1 CONTRACT AT MARKET
    stopLevel = lowest[5](low) // stop initial
    SET STOP pLOSS (close - stopLevel) * pipsize
    ENDIF
    // Entrée en short
    IF isTradingDay AND isTradingHour AND reversalDown THEN
    SELLSHORT 1 CONTRACT AT MARKET
    stopLevel = highest[5](high)
    SET STOP pLOSS (stopLevel - close) * pipsize
    //ENDIF // ============================ // STOP SUIVEUR DYNAMIQUE // ============================
    IF longonmarket THEN
    profitPoints = close - tradeprice(1) // Activation du stop suiveur à +8 points IF profitPoints >= 8 THEN
    newStop = tradeprice(1) + 2 // +2 points au-dessus du prix d’entrée
    step = FLOOR((profitPoints - 8) / 4)
    newStop = MAX(newStop, tradeprice(1) + step * 4 + 2)
    SET STOP ploss (tradeprice(1) - newStop) * pipsize
    ENDIF
    ENDIF
    
    IF shortonmarket THEN
    profitPoints = tradeprice(1) - close
    
    IF profitPoints >= 8 THEN
    newStop = tradeprice(1) - 2 // -2 points sous le prix d’entrée
    step = FLOOR((profitPoints - 8) / 4)
    newStop = MIN(newStop, tradeprice(1) - step * 4 - 2)
    SET STOP ploss (newStop - tradeprice(1)) * pipsize
    ENDIF
    ENDIF
    
    // ============================
    // CLÔTURE FORCÉE À 20h00
    // ============================
    IF time >= 200000 THEN
    IF longonmarket THEN
    SELL AT MARKET
    ENDIF
    IF shortonmarket THEN
    EXITSHORT AT MARKET
    ENDIF
    ENDIF
    
    Iván González thanked this post
    #250358 quote
    robertogozzi
    Moderator
    Master

    La définition correcte des bougies HA est la suivante :

    // — Heikin Ashi —
    haClose = (open + high + low + close) / 4
    once xOpen = open
    IF BarIndex > 0 THEN
       haOpen  = (haOpen[1] + haClose[1]) / 2
    ENDIF
    haHigh  = max(high, max(haOpen, haClose))
    haLow   = min(low, max(haOpen, haClose))
    Iván González thanked this post
    #250359 quote
    GraHal
    Participant
    Master

    La version ci-jointe (j’ai corrigé l’erreur dans le code ci-dessus) prend les transactions sur DAX M2.

    Cedric-HAshi-DAX-M2-10K-v1.itf
    #250363 quote
    Cédric Froidefond
    Participant
    Junior

    Ok merci les modifications, avait vous pu backtest la stratégie.

    #250365 quote
    GraHal
    Participant
    Master

    Oui, voulez-vous voir les résultats du backtest ?

    Ne pouvez-vous pas backtester le fichier .itf que j’ai posté ci-dessus ? 

    #250366 quote
    Cédric Froidefond
    Participant
    Junior

    Le problème j’ai pas encore accès prorealtime, et oui je veux bien les résultats si ça vous dérange pas.

    Merci.

    #250371 quote
    GraHal
    Participant
    Master

    Voir ci-joint. Je n’ai pas réussi à le rendre aussi parfait que possible. 

    Votre code publié n’ouvrirait pas de transactions ; il y avait plusieurs erreurs, j’ai trié ces erreurs et le résultat est joint.

    Si vous voulez voir les modifications que j’ai apportées, entrez votre code et mon code (dans le fichier .itf) dans ce « diffchecker ».  

    https://www.diffchecker.com/

    r4qEqF1rS4.jpg r4qEqF1rS4.jpg Uhb6bCTbNq.png Uhb6bCTbNq.png
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.

Stratégie pattern de retournement


ProOrder : Trading Automatique & Backtests

New Reply
Summary

This topic contains 9 replies,
has 3 voices, and was last updated by GraHal
5 months, 3 weeks ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 09/04/2025
Status: Active
Attachments: 5 files
Logo Logo
Loading...