Probacktest Extratrend

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #225666 quote
    CAAZY
    Participant
    New

    Bonjour,

    Après avoir repris le code vu sur une vidéo de Christophe concernant la backtest d’une stratégie via l’indicateur Extratrend, je me retrouve dans l’impasse.

    En effet, le backtest me retourne aucun résultat…

    Pouvez-vous m’indiquer le problème s’il vous plait ?

    Bien à vous,

    Cordialement,

    Code :

    DEFPARAM CumulateOrders=False

    capitalinitial=1000
    risque=0.5
    exitstrategy=1
    profitfactor=6
    stopfactor=1.5
    partialprofit=1
    partialprofitfactor=3
    ratchetfactor=7

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

    // Tendance Extratrend
    if myTrend>myTrend[1] THEN
    tendance=1
    ENDIF
    if myTrend>myTrend[1] THEN
    tendance=0
    ENDIF

    if tendance and not tendance[1] and not LONGONMARKET 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

    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

    if LONGONMARKET and exitstrategy=1 and close<lowest[30](highest[55](high)-ratchetfactor*averagetruerange[20]) THEN
    sell at market
    ENDIF

    #225675 quote
    Alain
    Participant
    Senior

    Bonjour.

    Il y a une erreur dans la définition de la variable Tendance. La condition est la même pour mettre cette variable à 1 ou à 0.

    Donc en fait Tendance est. toujours à 0 et la condition d’achat est toujours fausse.

    Je suppose que vous vouliez écrire

    if myTrend < myTrend[1] THEN
    tendance=0
    ENDIF
    
    
    
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Probacktest Extratrend


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
CAAZY @caazy Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Alain
2 years, 2 months ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 12/23/2023
Status: Active
Attachments: No files
Logo Logo
Loading...