Extratrend stratégie en un indicateur

Viewing 14 posts - 16 through 29 (of 29 total)
  • Author
    Posts
  • #196048 quote
    HienAlpha
    Participant
    New

    J’avais tenté de marquer cela comme suit, mais il me dit qu’il y a une erreur à la ligne 86. Je suis un peu bloqué :

    capitalinitial=10000
    risque=1
    exitstrategy=1
    profitfactor=6
    stopfactor=1.5
    partialprofit=1
    partialprofitfactor=3
    ratchetfactor=7
    // PULLBACK CONDITIONS
    SMA20= Average[20](close)
    PB = (close <= SMA20)

    // Appel des valeurs d’ExtraTrend
    myTrend, ignored, ignored, myReDyn, ignored = CALL “ExtraTrend”[0,0,0,0,0](close)

    // Tendance ExtraTrend
    if myTrend>myTrend[1] then
    tendance=1
    endif
    if myTrend<myTrend[1] then
    tendance=0
    endif

    // Break Résistance Dynamique ExtraTrend
    if myReDyn>myReDyn[1] then
    ReDyn=1
    endif
    if myReDyn<myReDyn[1] then
    ReDyn=0
    endif

    // score Metascore
    myScore, ignored, ignored = CALL “MetaScore”[80, 0, 0](close)

    //STRATEGIES OF BUY
    // Entrée début de tendance
    if tendance and not tendance[1] and not ionmarket and myscore>80 and ReDyn=1 THEN
    drawarrowup(barindex,low-AverageTrueRange[14](close)/2) coloured(“black”)
    istoploss = close-stopfactor*averagetruerange[20]
    //set stop loss stopfactor*averagetruerange[20]
    if exitstrategy=0 then
    itakeprofit = close+profitfactor*averagetruerange[20]
    //set target profit profitfactor*averagetruerange[20]
    endif
    flag=0
    ionmarket=1
    endif

    // Pullback dans tendance
    if tendance[1] and not ionmarket and myScore>80 and PB THEN
    drawarrowup(barindex,low-AverageTrueRange[14](close)/2) coloured(“black”)
    istoploss = close-stopfactor*averagetruerange[20]
    //set stop loss stopfactor*averagetruerange[20]
    if exitstrategy=0 then
    itakeprofit = close+profitfactor*averagetruerange[20]
    //set target profit profitfactor*averagetruerange[20]
    endif
    flag=0
    ionmarket=1
    endif

    if ionmarket and close>=myTrend+partialprofitfactor*averagetruerange[20] and flag=0 and partialprofit=1 then
    drawtext(“X”,barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured(“green”)
    flag=1
    endif

    if ionmarket and exitstrategy=1 and close<lowest[30](highest[55](high)-ratchetfactor*averagetruerange[20])then
    drawtext(“OUT”,barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured(“black”)
    ionmarket=0
    endif

    //test stoploss & takeprofit
    if ionmarket then
    if high >= itakeprofit and exitstrategy=0 then
    drawtext(“TP”,barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured(“black”)
    ionmarket=0
    elsif low <= istoploss then
    drawtext(“SL”,barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured(“red”)
    ionmarket=0
    endif
    endif

    return itakeprofit style(dottedline2) coloured(“green”), istoploss style(dottedline3) coloured(“black”)

    //STRATEGIES OF SELL
    IF tendance[0] and not sonmarket and myScore<20 and not ionmarket then
    drawarrowdown(barindex,low-AverageTrueRange[14](close)/2) coloured(“red”)
    sstoploss = close-stopfactor*averagetruerange[20]
    //set stop loss stopfactor*averagetruerange[20]
    IF exitstrategy=0 then
    stakeprofit = close+profitfactor*averagetruerange[20]
    //set target profit profitfactor*averagetruerange[20]
    endif
    flag=0
    sonmarket=1
    endif

    if sonmarket and close>=myTrend+partialprofitfactor*averagetruerange[20] and flag=0 and partialprofit=1 then
    drawtext(“X”,barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured(“green”)
    flag=1
    endif

    if sonmarket and exitstrategy=1 and close<lowest[30](highest[55](high)-ratchetfactor*averagetruerange[20])then
    drawtext(“OUT”,barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured(“black”)
    sonmarket=0
    endif

    //test stoploss & takeprofit
    if sonmarket then
    if high >= stakeprofit and exitstrategy=0 then
    drawtext(“TP”,barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured(“black”)
    sonmarket=0
    elsif low <= sstoploss then
    drawtext(“SL”,barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured(“red”)
    sonmarket=0
    endif
    endif

    return stakeprofit style(dottedline2) coloured(“green”), sstoploss style(dottedline3) coloured(“black”)

    #196091 quote
    Keyeming
    Participant
    Junior

    Bonjour Nicolas,

    Merci beaucoup pour le code, cependant il reste un point que je n’arrive à comprendre et je n’arrive pas à avoir de réponse de Christophe.

    En mettant exitstrategy=0, je ne trouve jamais une occurence de “TP” pour laquelle on aurait donc le Take profit total et non pas partiel.

    As tu un exemple sur lequel on peut voir le “TP”?  qui déclencherait donc le drawtext(“TP”,barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured(“green”)

    Merci,

    #196121 quote
    gillespetitbali
    Participant
    Junior

    Bonjour à tous.

    J’ai humblement essayé différentes stratégies avec Extratrend, et les résultats que j’obtiens sont radicalement différents d’un Timeframe à l’autre. De ce que j’ai compris ca marche mieux sur les UT longues genre daily, car les tendances sont plus claires, car logiquement beaucoup moins de faux signaux, de bruits, de gaps, etc… Ca devient beaucoup plus compliqué quand on descend les UT genre 15 min, la performance est anéantie par des titres en range pleins de faux signaux, et même en utilisant des gardes fous genre Metascore + multi timeframe pour être sûr d’être en tendance en Journalier & 1 heure, avant de prendre une position en 15 min quand metascore au-dessus de 90, les résultats sont peu convaincants, je vous partage ici le dernier code a ce sujet inspiré de ce qu’a proposé Christophe et d’autres participants de ce file ( que je remercie).
    En bref je suis toujours en recherche d’une stratégie efficace en UT courte pour avoir la meilleure performance en un minimum de temps.
    J’ai aussi testé une stratégie de sortie de position via un stop inspiré des Tortues, ca marche mieux que le stop ratchet de Christophe dans quelques cas, mais le plus souvent le stop de Christophe est plus efficace, tout depends du titre tradé…

    DEFPARAM CumulateOrders=False
    
    capitalinitial=10000
    risque=3
    profitfactor=6
    stopfactor=1.5
    partialprofit=1
    partialprofitfactor=3
    ratchetfactor=7
    META=90
    Sortie=1
    p=20
    
    TIMEFRAME (1 DAY)
    
    //APPEL VALEUR EXTRATREND DAILY
    myTrendD, ignored, ignored, ignored, ignored = CALL "ExtraTrend"[0,0,0,0,0](close)
    
    // Tendance ExtraTrend DAILY
    if myTrendD>myTrendD[1] then
    tendanceD=1
    endif
    if myTrendDmyTrendH[1] then
    tendanceH=1
    endif
    if myTrendHmyTrend[1] then
    tendance=1
    endif
    if myTrend META THEN
    INDIC=1
    ELSE
    INDIC=0
    ENDIF
    
    //PRISE DE POSITION
    if tendance and tendanceD and tendanceH and INDIC=1 and not longonmarket THEN
    positionsize=round(((capitalinitial)*(risque/100))/(stopfactor*averagetruerange[20]))
    BUY positionsize shares AT MARKET
    set stop loss stopfactor*averagetruerange[20]
    flag=0
    endif
    
    // PROFIT PARTIEL
    if longonmarket and close>=myTrend+partialprofitfactor*averagetruerange[20] and flag=0 and partialprofit=1 then
    sell round(positionsize/2) shares at market
    flag=1
    endif
    
    //SORTIE DE POSITION 1
    if sortie=1 and longonmarket and close ATRts THEN
    ATRnew = close - ATRx
    IF ATRnew > ATRts THEN
    ATRts = ATRnew
    ENDIF
    ELSIF close < ATRts THEN
    ATRnew = close + ATRx
    IF ATRnew < ATRts THEN
    ATRts = ATRnew
    ENDIF
    ENDIF
    
    //SORTIE DE POSITION 2
    if sortie=2 and longonmarket and close
    #196122 quote
    gillespetitbali
    Participant
    Junior

    J’ai aussi testé une autre stratégie basée sur la cassure de la resistance dynamique, et dans le meme esprit que la précédente les résultats sont bons quand la tendance est belle longue et bien établie, mais dès qu’on descend les unités de Temps avec un graphique sans tendance clair, alors rien ne va plus… (Voir screenshot)
    Pas facile de trouver le meilleur des 2 mondes.

    capitalinitial=10000
    risque=3
    stopfactor=1.5
    partialprofit=1
    partialprofitfactor=3
    p =20
    
    // ATRx
    ATRx = AverageTrueRange[p](close) * 3
    
    //ATRs = ATR Trailing Stop ou Stop Tortues
    IF close crosses over ATRts THEN
    ATRts = close - ATRx
    ELSIF close crosses  under ATRts THEN
    ATRts = close + ATRx
    ENDIF
    
    // Clalcul del'ATRts lors de la meme tendance
    IF close > ATRts THEN
    ATRnew = close - ATRx
    IF ATRnew > ATRts THEN
    ATRts = ATRnew
    ENDIF
    ELSIF close < ATRts THEN
    ATRnew = close + ATRx
    IF ATRnew < ATRts THEN
    ATRts = ATRnew
    ENDIF
    ENDIF
    
    
    //APPEL VALEUR EXTRATREND
    myTrend, ignored, ignored, myReDyn, ignored = CALL "ExtraTrend"[0,1,0,0,0](close)
    
    //APPEL MM
    mm200 = average[200]
    mm50 = average[50]
    mm20 = average[20]
    
    //CONDITION MM
    IF MM50>MM200 THEN
    COND1=1
    ELSE
    COND1=0
    ENDIF
    
    IF MM20>MM50 THEN
    COND2=1
    ELSE
    COND2=0
    ENDIF
    
    //CASSURE RES DYN
    If myTrend[1]<>myReDyn[1] and close>myReDyn[1] and close>mm200 THEN
    Cassure=1
    else
    cassure=0
    endif
    
    //PRISE DE POSITION
    if Cassure=1 and cond1=1 and not longonmarket  THEN
    positionsize=round(((capitalinitial)*(risque/100))/(stopfactor*averagetruerange[20]))
    BUY positionsize shares AT MARKET
    set stop loss stopfactor*averagetruerange[20]
    flag=0
    endif
    
    // PROFIT PARTIEL
    if longonmarket and close>=myTrend+partialprofitfactor*averagetruerange[20] and flag=0 and partialprofit=1 then
    sell round(positionsize/2) shares at market
    flag=1
    endif
    
    //SORTIE DE POSITION
    if longonmarket and close
    Capture-decran-2022-06-26-a-11.20.06.jpg Capture-decran-2022-06-26-a-11.20.06.jpg Capture-decran-2022-06-26-a-11.20.52.jpg Capture-decran-2022-06-26-a-11.20.52.jpg
    #196125 quote
    Axel98
    Participant
    Average

    Bonjour,

    Ce n’est peut-être pas le but de l’indicateur Extratrend d’entrer sur des positions “short” lorsqu’une nouvelle tendance baissière s’amorce (bande grise sans bande bleue), mais est-ce que quelqu’un aurait déjà essayer d’ajouter un bout de code pour essayer ?

    #196126 quote
    Axel98
    Participant
    Average

    désolé ne tenez pas compte de mon précédent message je n’avais pas vu qu’il y avait un essai avec une partie “short” dans la page précédente !

    #196447 quote
    HienAlpha
    Participant
    New

    Bonjour à tous,

    Je vous partage ma version actuelle de stratégie long/short qui fait appel à Extratrend :

    DEFPARAM CumulateOrders=False
    
    capitalinitial=100000
    risque=0.25
    exitstrategy=1
    profitfactor=6
    stopfactor=1.5
    partialprofit=1
    partialprofitfactor=3
    ratchetfactor=7
    
    // PULLBACK CONDITIONS
    SMA50= Average[50](close)
    SMA20= Average[20](close)
    PB = (close <= SMA20)
    
    // THROWBACK CONDITIONS
    SMA20= Average[20](close)
    TB = (close >= SMA20)
    
    //myTrend, ignored, ignored = CALL "ExtraTrend v2" [0,0,0,0,0](close)
    myTrend, ignored, ignored, myReDyn, ignored = CALL "ExtraTrend"[0,0,0,0,0](close)
    
    // Tendance ExtraTrend
    if myTrend>myTrend[1] then
    tendance=1
    endif
    if myTrend<myTrend[1] then
    tendance=0
    endif
    
    // Metascore
    myScore, ignored, ignored = CALL "MetaScore"[0,0,0](close)
    
    //STRATEGIES OF IRIMI BUY
    
    // Début tendance
    if tendance and not tendance[1] and not longonmarket and not shortonmarket and myScore>80 THEN
    //if not longonmarket then
    positionsize=round(((capitalinitial+STRATEGYPROFIT)*(risque/100))/(stopfactor*averagetruerange[20]))
    
    //positionsize=round(((capitalinitial+STRATEGYPROFIT)/close)
    BUY positionsize shares AT MARKET
    set stop loss stopfactor*averagetruerange[20]
    if exitstrategy=0 then
    set target profit profitfactor*averagetruerange[20]
    endif
    flag=0
    endif
    
    // Pullback dans tendance
    if tendance[1] and not longonmarket and not shortonmarket and myScore>80 and PB THEN
    
    //if not longonmarket then
    positionsize=round(((capitalinitial+STRATEGYPROFIT)*(risque/100))/(stopfactor*averagetruerange[20]))
    
    
    //positionsize=round(((capitalinitial+STRATEGYPROFIT)/close)
    BUY positionsize shares AT MARKET
    set stop loss stopfactor*averagetruerange[20]
    if exitstrategy=0 then
    set target profit profitfactor*averagetruerange[20]
    endif
    flag=0
    endif
    
    // SORTIE LONG
    // Sell in strenght
    if longonmarket and close>=myTrend+partialprofitfactor*averagetruerange[20] and flag=0 and partialprofit=1 then
    sell round(positionsize/2) shares at market
    flag=1
    endif
    
    // Sell out
    if longonmarket and exitstrategy=1 and close<lowest[30](highest[55](high)-ratchetfactor*averagetruerange[20])then
    sell at market
    endif
    
    //STRATEGIES OF IRIMI SELL
    
    // Début short
    if tendance[0] and not longonmarket and not shortonmarket and myScore<20 THEN
    
    //if not ShortOnMarket then
    positionsize=round(((capitalinitial+STRATEGYPROFIT)*(risque/100))/(stopfactor*averagetruerange[20]))
    
    //positionsize=round(((capitalinitial+STRATEGYPROFIT)/close)
    SELLSHORT positionsize shares AT MARKET
    set stop loss stopfactor*averagetruerange[20]
    if exitstrategy=0 then
    set target profit profitfactor*averagetruerange[20]
    endif
    flag=0
    endif
    
    // Throwback dans short
    if tendance[0] and not longonmarket and not shortonmarket and myScore<20 and TB THEN
    
    //if not longonmarket then
    positionsize=round(((capitalinitial+STRATEGYPROFIT)*(risque/100))/(stopfactor*averagetruerange[20]))
    
    //positionsize=round(((capitalinitial+STRATEGYPROFIT)/close)
    SELLSHORT positionsize shares AT MARKET
    set stop loss stopfactor*averagetruerange[20]
    if exitstrategy=0 then
    set target profit profitfactor*averagetruerange[20]
    endif
    flag=0
    endif
    
    // RENFORCEMENT SHORT
    if tendance[0] and shortonmarket and myScore<20 and TB THEN
    
    //if not longonmarket then
    positionsize=round(((capitalinitial+STRATEGYPROFIT)*(risque/100))/(stopfactor*averagetruerange[20]))
    
    //positionsize=round(((capitalinitial+STRATEGYPROFIT)/close)
    SELLSHORT (positionsize/2) shares AT MARKET
    set stop loss stopfactor*averagetruerange[20]
    if exitstrategy=0 then
    set target profit profitfactor*averagetruerange[20]
    endif
    flag=0
    endif
    
    // SORTIE SHORT
    if shortonmarket and close>=myTrend+partialprofitfactor*averagetruerange[20] and flag=0 and partialprofit=1 then
    sell round(positionsize/2) shares at market
    flag=1
    endif
    
    if shortonmarket and exitstrategy=1 and close<lowest[30](highest[55](high)-ratchetfactor*averagetruerange[20])then
    exitshort at market
    endif
    

    J’ai fait comme j’ai pu pour transformer cette stratégie en indicateur pour l’utiliser en temps réel sur mes graphiques. Je ne suis pas certain de la partie “Renforcement Short” :

    capitalinitial=10000
    risque=1
    exitstrategy=1
    profitfactor=6
    stopfactor=1.5
    partialprofit=1
    partialprofitfactor=3
    ratchetfactor=7
    
    // PULLBACK CONDITIONS
    SMA20= Average[20](close)
    PB = (close <= SMA20)
    // THROWBACK CONDITIONS
    SMA20= Average[20](close)
    TB = (close >= SMA20)
    
    // Appel des valeurs d'ExtraTrend
    myTrend, ignored, ignored, myReDyn, ignored = CALL "ExtraTrend"[0,0,0,0,0](close)
     
    // Tendance ExtraTrend
    if myTrend>myTrend[1] then
    tendance=1
    endif
    if myTrend<myTrend[1] then
    tendance=0
    endif
    
    // score Metascore
    myScore, ignored, ignored = CALL "MetaScore"[80, 0, 0](close)
    
    //STRATEGIES OF BUY
    // Entrée début de tendance
    if tendance and not tendance[1] and not ionmarket and not sonmarket and myscore>80 THEN
    drawarrowup(barindex,low-AverageTrueRange[14](close)/2) coloured("black")
    istoploss = close-stopfactor*averagetruerange[20]
    //set stop loss stopfactor*averagetruerange[20]
    if exitstrategy=0 then
    itakeprofit = close+profitfactor*averagetruerange[20]
    //set target profit profitfactor*averagetruerange[20]
    endif
    flag=0
    ionmarket=1
    endif
     
    // Pullback dans tendance
    if tendance[1] and not ionmarket and not sonmarket and myScore>80 and PB THEN
    drawarrowup(barindex,low-AverageTrueRange[14](close)/2) coloured("black")
    istoploss = close-stopfactor*averagetruerange[20]
    //set stop loss stopfactor*averagetruerange[20]
    if exitstrategy=0 then
    itakeprofit = close+profitfactor*averagetruerange[20]
    //set target profit profitfactor*averagetruerange[20]
    endif
    flag=0
    ionmarket=1
    endif
    
    // LONG Take Profit
    if ionmarket and close>=myTrend+partialprofitfactor*averagetruerange[20] and flag=0 and partialprofit=1 then
    drawtext("X",barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured("green")
    flag=1
    endif
     
    // LONG Exit
    if ionmarket and exitstrategy=1 and close<lowest[30](highest[55](high)-ratchetfactor*averagetruerange[20])then
    drawtext("OUT",barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured("black")
    ionmarket=0
    endif
     
    // LONG stoploss & takeprofit
    if ionmarket then
    if high >= itakeprofit and exitstrategy=0 then
    drawtext("TP",barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured("black")
    ionmarket=0
    elsif low <= istoploss then
    drawtext("SL",barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured("red")
    ionmarket=0
    endif
    endif
    
    //STRATEGIES OF SELL
    
    // Initiation Short
    if tendance[0] and myScore<20 and not sonmarket and not ionmarket then
    drawarrowdown(barindex,low-AverageTrueRange[14](close)/2) coloured("black")
    sstoploss = close+stopfactor*averagetruerange[20]
    //set stop loss stopfactor*averagetruerange[20]
    if exitstrategy=0 then
    stakeprofit = close-profitfactor*averagetruerange[20]
    //set target profit profitfactor*averagetruerange[20]
    endif
    flag=0
    sonmarket=1
    endif
    
    // Throwback Short
    if tendance[0] and myScore<20 and not sonmarket and not ionmarket and TB then
    drawarrowdown(barindex,low-AverageTrueRange[14](close)/2) coloured("black")
    sstoploss = close+stopfactor*averagetruerange[20]
    //set stop loss stopfactor*averagetruerange[20]
    if exitstrategy=0 then
    stakeprofit = close-profitfactor*averagetruerange[20]
    //set target profit profitfactor*averagetruerange[20]
    endif
    flag=0
    sonmarket=1
    endif
    
    // Renforcement short
    //if tendance[0] and sonmarket and not ionmarket and myScore<20 and TB THEN
    //drawarrowdown(barindex,low-AverageTrueRange[14](close)/2) coloured("blue")
    //sstoploss = close+stopfactor*averagetruerange[20]
    //set stop loss stopfactor*averagetruerange[20]
    //if exitstrategy=0 then
    //stakeprofit = close-profitfactor*averagetruerange[20]
    //set target profit profitfactor*averagetruerange[20]
    //endif
    //flag=0
    //sonmarket=1
    //endif
    
    // SHORT Take Profit
    if sonmarket and close<=myTrend-partialprofitfactor*averagetruerange[20] and flag=0 and partialprofit=1 then
    drawtext("X",barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured("green")
    flag=1
    endif
    
    // SHORT Exit
    if sonmarket and exitstrategy=1 and close>lowest[30](highest[55](high)+ratchetfactor*averagetruerange[20])then
    drawtext("OUT",barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured("black")
    sonmarket=0
    endif
     
    // SHORT stoploss & takeprofit
    if sonmarket then
    if low <= stakeprofit and exitstrategy=0 then
    drawtext("TP",barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured("black")
    sonmarket=0
    elsif high >= sstoploss then
    drawtext("SL",barindex,high+AverageTrueRange[14](close)/2,dialog,bold,20) coloured("red")
    sonmarket=0
    endif
    endif
     
    return itakeprofit style(dottedline2) coloured("green"), istoploss style(dottedline3) coloured("black"), stakeprofit style(dottedline2) coloured("green"), sstoploss style(dottedline3) coloured("red")
    

    Je suis vraiment très débutant en codage sur PRT. Donc si des personnes clémentes acceptent de vérifier mes codes, je leur en serai gré. Ils doivent sans doute comporter des erreurs.

    Au plaisir d’échanger ensemble.

    ssopiak thanked this post
    #196449 quote
    HienAlpha
    Participant
    New

    Notamment la partie SHORT de l’indicateur, je ne suis pas très sûr de la véracité de mon codage. J’ai peur que cela ne relate pas la stratégie du backtesting.

    #196496 quote
    HienAlpha
    Participant
    New

    Nicolas,

    Je ne sais pas si tu peux y jeter un oeil stp ?

    Car je galère vraiment à transformer ma stratégie en indicateur.

    Merci d’avance,

    Thibaut

    #199503 quote
    plbourse
    Participant
    New

    Bonjour

     

    J’ai codé une stratégie longue en utilisant ExtraTrend et Metascore avec les caractéristiques suivantes

    • Entrée avec Stop Loss, pour la définition de la taille de position
    • 2  possibilités de pyramidage avec le même nombre de titres
    • Cloture sur StopSuiveur dans toute la durée de trade

    Il y a une conditon supplémentaire, attente d’au minimum 20 barres après la clôture avant de reprendre un position

    Cette stratégie est globalement gagnante (de très beaux ^rofits lorsque l’on prend une tendance) mais elle est impactée par les éléments suivants

    • Trop de trades proposés
    • le pourcentage de trades perdants est beaucoup trop important

    Je cherche donc à filtrer mieux mes entrées, dans l’espoir de réduire le % de trades perdants.

    L’un de vous aurait-il une bonne idée pour filtrer les entrées ?

    Au plaisir de vous lire et bons trades… à tous

    ssopiak thanked this post
    #199546 quote
    ssopiak
    Participant
    Junior

    Bonsoir,

    votre post a suscité mon intérêt, je serai intéressé pour jeter un oeil à votre code 🙂

    Concernant votre question, difficile de répondre mais peut-être qu’en filtrant avec le metascore pourrait être intéressant.

    On pourrait imaginer par exemple :

    • ne prendre que les signaux pour lesquels le metascore est au-dessus d’un seuil
    • ou bien ne prendre que les signaux pour lesquels le metascore est en hausse par rapport à la période précédente
    • ou bien le metascore est supérieur à la moyenne des metascore des x dernières périodes

    Dans tous les cas, il est certain que faire des backtests pour tester les config profitable est une bonne approche 🙂

    Bonne continuation.

    #199635 quote
    ssopiak
    Participant
    Junior

    Oups j’ai vu que mon message n’était pas en “reply” du tien mais c’etait bien une réponse à ton message …. https://www.prorealcode.com/topic/extratrend-strategie-en-un-indicateur/page/2/#post-199546

    #199660 quote
    plbourse
    Participant
    New

    Bonjour

    Je suis loin d’être un programmeur averti et mon code est assez compliqué. J’ai eu en particulier des difficultés pour réaliser les pyramidages, les reconnaitre et limiter leur nombre.

    Le code est prévu pour un investissement avec un risque de 250 € (capital initial de 100 k€, risque 0,25 % sur la position initiale, au minimum de 0,8 % si les 2 pyramidages sont réalisés

    L’objectif est de faire tourner ce backtest sur les principales Action Euronext, Allemagne, Nyse, Nasdaq, d’obtenir un portefeuille de trades classés par date de prise de position sur 10 ans du 1/01/2011 au 31/12/2020 (clôture des trades en cours imposée au 30/6/2021)

    Pour la simulation de portefeuille j’ai développé (encore en cours de modification pour étudier les options de Money Management) un programme Visual Basic 2019 qui réalise la simulation de portefeuille (positions, frais de bourse, calcul des taux de changes USD/EUR et frais de change).

    Sortie

    • liste détaillée des positions
    • capital final trades fermés
    • DrawDown maxi en % et absolu, date du DrawDown et Capital théorique maxi

    Tous les commentaires, simplifications, améliorations sont les bienvenus.

    Au plaisir de lire les réponses

     

     

    // Nouveau backtest selon ProRealCode GillesPetitBal
    // Post du 27/06/2022
    // idem 1, mais recherche pour supprimer le trop grand nombre de pyramidage
    
    // on a rajouté
    // Conditon sur le CA tradé par jour
    //Conditon sur les volumes pour l'entrée en position
    // UpTrendWeekly[1] en Hausse
    
    // Bilan,
    // malheureusement, on pyramide jsuqu'à 3 ou 4 fois, bug à corriger
    // Trop de trades sur 2 ou 3 barres, ce qui laisse supposer que le Stop Initial est trop serré
    
    //Conditions pour ouvrir une position acheteuse
    // 1.1 le titre est en zone de force sur son unité classique
    // 1.2 Close est > MM200 en weekly
    // 1.3 Close est > MM7 dans l'unité du Trade
    
    // Pas de conditoin initialement sur les volumes
    
    // Prise de position sur 1/2 Position avec 1,5 ATR de Stop
    // Stop suiveur à 3 ATR
    
    // 1er pryramidage de 1/2 Position si le cours atteint Cours d'entrée + 4 ATR
    // 2ième pyramidage de 1/2 Position si le cours casse sa résistance dynamique
    
    // Vente sur Stop Loss, pas de vente partielle
    // Pas de condition sur ExtraTrend
    
    // Parametres
    // On intyroduit dans cette section les paramètres généraux du Trading
    
    once DateDebut = 20110101
    once DateFin = 20201231
    once DateClotureTrade = 20210630
    once NbATRStop = 3
    once CoefVolumes = 2.5
    once DurMinEntreTrade = 20
    once SeuilMetascore = 85
    
    
    // Définition des valeurs en Weekly
    Timeframe(weekly)
    Cond2 = close > Average[200](close)
    myTrendWeekly, ignored, myExpansionWeekly, myResDynWeekly, ignored = CALL "ExtraTrend"[0, 1, 0, 0, 1, 0](close)
    UptrendWeekly = myExpansionWeekly > myTrendWeekly
    Cond4 = UpTrendWeekly[1]
    
    // Fin des conditions en weekly
    
    // on revient en deaily
    timeframe(daily)
    
    // condition sur les dates
    CondDate = (Date >= DateDebut) and (Date < DateFin)
    
    // Condition sur les volumes trades par jour
    moyvolTradeCT = average[5](volume)*average[5](close)
    CondVolTrade = moyvolTradeCT >= 100000
    
    // Condition sur l'évolution des volumes
    CondTrendVol = Volume >= CoefVolumes*Average[20](Volume)[10]
    
    // Traitement de UpTrend en daily
    myTrendDaily, ignored, myExpansionDaily, myResDynDaily, ignored = CALL "ExtraTrend"[0, 1, 0, 0, 1, 0](close)
    UptrendDaily = myExpansionDaily > myTrendDaily
    Cond1 = UpTrendDaily
    Cond3 = Close > Average[7](close)
    
    // Condition sur Metascore
    myMetaScore, ignored, ignored = CALL "MetaScore"[0,0,20](close)
    CondMetascore = myMetascore >= SeuilMetascore
    
    // Dimensionnement de la position
    if Not LongonMarket then
    
    StopLossIni = Close - 3 * AverageTRueRange[14](Close)
    TaillePos = 250/(Close -StopLossIni)
    TaillePos = Round(TaillePos-0.5)
    TaillePos = TaillePos - (TaillePos MOD 2)
    StopLoss = StopLossIni
    if NbPos <> 0 then
    NbPos = 0
    endif
    Endif
    
    
    // Condition sur le dernier Trade
    // Condition depuis la dernière sortie
    CondLastTrade = 1
    For j = 1 to DurMinEntreTrade
    if LongonMarket[j] then
    CondLastTrade = 0
    endif
    next
    
    // fin de la boucle For
    
    CondAch = CondDate
    CondAch = CondAch and Cond1
    CondAch = CondAch and Cond2
    CondAch = CondAch and Cond3
    CondAch = CondAch and Cond4
    CondAch = CondAch and CondVolTrade
    CondAch = CondAch and CondTrendVol
    CondAch = CondAch and CondLastTrade
    CondAch = CondAch and CondMetascore
    
    // Vente sur StopLoss
    if LongonMarket and longonmarket[1] then
    sell at Stoploss Stop
    Endif
    
    // Définition de ATRRef
    If LongonMarket and Not LongonMarket[1] then
    ATRRef = AverageTrueRange[14](Close)[1]
    Entryprice = Positionprice
    Endif
    
    // Réevaluation du StopLoss
    if LongOnMarket and Close- 3*ATRRef > StopLoss then
    Stoploss = Close-3*ATRRef
    Endif
    
    // Reconnaissance de Pyramidage 1
    // il faut mettre la reconnaissance du Pyramidage avant le pyramidage pour ne pas doubler le pyramidage
    if LongonMarket and LongonMarket[1] and CountofPosition <> CountofPosition[1] and High[1] >= (EntryPrice + 4*ATRRef) and CondPyram1 = 0  then
    // Le Pyramidage 1 a été réalisé
    CondPyram1 = 1
    endif
    
    if LongonMarket and CountofPosition <> CountofPosition[1] then
    NbPos = NbPos + 1
    endif
    
    // Pyramidage 1
    if LongOnMarket and CondPyram1 = 0 and CondPyram2 = 0 and NbPos <= 2 then
    Buy TaillePos Shares at EntryPrice + 4*ATRRef Stop
    endif
    
    // Reconnaissance de Pyramidae 2, également à mettre avant
    If LongOnMarket and LongonMarket[1] and CountOfPosition <> CountOfPosition[1] and Close[1] crosses over myResDynDaily[1] and CondPyram2 = 0 then
    CondPyram2 = 1
    Endif
    
    // Pyramidage 2
    if LongonMarket and CondPyram1 = 1 and CondPyram2 = 0 and Close crosses over myResDynDaily and NbPos <= 2 then
    Buy TaillePos Shares at Market
    Endif
    
    // REmise à 0 des Pyramidages après vente
    if Not LongonMarket and LongonMarket[1] then
    CondPyram1 = 0
    CondPyram2 = 0
    endif
    
    // Achat
    if CondAch and Not longonmarket then
    Buy TaillePos shares at market
    CondPyram1 = 0
    CondPyram2 = 0
    Endif
    
    
    if OnMarket and Date >= DateClotureTrade then
    Sell at market
    endif
    // fin de if Longonmarket and Date > DateClotureTrade
    // Sortie après la période de Trade
    
    ssopiak thanked this post
    #202369 quote
    plbourse
    Participant
    New

    Bonjour à tous

    je vous annonce avoir crée un nouveau sujet dans le forum Discussion Generale sur le Trading, sujet nommé

    Backtests et Screeners Base TrendFrance (Monsterstock, ExtraTrend, Metascore) #202362

    Backtests et screeners Base TrendFrance (Monsterstock, ExtraTrend, Metascore)

    Merci par avance pour vos contributions

    Bons trades à tous

    plbourse

    Nicolas thanked this post
Viewing 14 posts - 16 through 29 (of 29 total)
  • You must be logged in to reply to this topic.

Extratrend stratégie en un indicateur


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
HienAlpha @hienalpha Participant
Summary

This topic contains 28 replies,
has 8 voices, and was last updated by plbourse
3 years, 5 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 05/23/2022
Status: Active
Attachments: 3 files
Logo Logo
Loading...