Besoin de comprendre un code, backtest 100% gagnant

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

    Bonjour à tous,

    je suis tomber sur le code ci dessous et je souhaiterais comprendre quelque chose, sur les backtest en m5 sur le dax, us tech et cac 40, l’aLgo affiche toujours 100% de trades gagnant,

    peut importe le nombre de bougies backtester, est ce que j’aurais enfin trouver le graal ou est ce que c’est un bug du backtest ?

    CI-dessous le code:

    //-----------------------------------------------------------------------------------------------
    //TF a 12 h
    //dax min 1 Eur.
    //-----------------------------------------------------------------------------------------------
    //TAKE PROFIT NEAR ZERO IN ORDER TO NOT ACCUMULATE TOO MUCH
    //-----------------------------------------------------------------------------------------------
    //IF NOT ON MARKET TRY TO ENTER AGAIN AS SOON A CORRECTION APPEARS, TRYING TO FOLLOW
    //THE POTENTIAL CURRENT UPTREND
    //-----------------------------------------------------------------------------------------------
    //IF I BOUGHT THE PREVIOUS BAR DON'T BUY THE FOLLOWING BAR IN ORDER TO NOT ACCUMULATE TOO MUCH
    //-----------------------------------------------------------------------------------------------
    //MAIN PARAMETER IN ORDER TO CHANGE THE RISK LEVEL ARE:
    //acc----> % of decrease of the instrument compared to the last buy price (THE LOWER IS AND MORE
    // RISK AND CASH RETURN WILL APEEAR)
    //-----------------------------------------------------------------------------------------------
    //tp-----> % beyond which the entire position is closed (THE HIGHER IS AND MORE
    // RISK AND CASH RETURN WILL APEEAR) - below zero is safer !
    //-----------------------------------------------------------------------------------------------
    //MONEY MANAGENT "ANTIMARTINGALA" STYLE - I SUPPOSE CLEARER RESULTS ON A LONGER PERIOD OF BACKTEST
    //-----------------------------------------------------------------------------------------------
    
    DEFPARAM cumulateorders = false
    DEFPARAM Preloadbars = 20000
    TIMEWORK = 070000
    TIMESTOP = 210000
    acc = 5
    
    if justone = 0 then
    capital = 10000 * pointvalue
    justone = 1
    endif
    
    perccap = 0.5
    margin = 0.5 * close * pointvalue / 100
    period=5
    stdev=STD[period](close)
    //LOOK FOR A LOCAL VOLATILITY DECREASE
    //I WANT TO BUY AGAIN ONLY WHEN BEAR MARKET SHOWS A LOCAL PAUSE
    if (stdev[0]+stdev[1]+stdev[2]+stdev[3]+stdev[4]) < (stdev[1]+stdev[2]+stdev[3]+stdev[4]+stdev[5]) then
    SWBUY=1
    else
    SWBUY=0
    ENDIF
    
    IF TIME > TIMEWORK AND TIME < TIMESTOP THEN
    if not onmarket then
    sizebuy = ROUND((capital *perccap /100)/ margin)
    tp = 0.25
    IF CLOSE < CLOSE[1] THEN
    BUY sizebuy SHARES AT MARKET
    endif
    endif
    
    if LONGONMARKET then
    perf = (close - POSITIONPRICE)/POSITIONPRICE * 100
    if perf > tp then
    SELl AT MARKET
    perfc = (close - POSITIONPRICE) * POINTVALUE * COUNTOFPOSITION
    capital = capital + PERFC
    ELSE
    IF LASTBARBUY = 0 THEN
    if (((CLOSE-TRADEPRICE)/TRADEPRICE)*100) < -acc AND SWBUY=1 then
    sizebuy = ROUND((capital *perccap /100)/ margin)
    BUY sizebuy SHARES AT MARKET
    LASTBARBUY = 1
    ENDIF
    ELSE
    LASTBARBUY = 0
    ENDIF
    ENDIF
    ENDIF
    ENDIF
    
    
    
    ProBacktest-indexbond-contrarian-orders-US-Tech-100-Cash-1E.png ProBacktest-indexbond-contrarian-orders-US-Tech-100-Cash-1E.png
    #216638 quote
    JC_Bywan
    Moderator
    Master

    Absence de stoploss dans le code = soit 100% de réussite, soit la perte totale de capital si elle se produit avant la sortie autorisée seulement en gains… “c’est vous qui voyez…”

    #216648 quote
    Nicolas
    Keymaster
    Master

    On gagne tout le temps si on perd jamais.

    #216747 quote
    FXtonio
    Participant
    New

    Bonjour,

     

    merci pour vos reponses, effectivement j’ai mis un stop loss et les backtest sont d’un seul coup beaucoup moins convaincant

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Besoin de comprendre un code, backtest 100% gagnant


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
FXtonio @fxtonio Participant
Summary

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

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 06/22/2023
Status: Active
Attachments: 1 files
Logo Logo
Loading...