Backtest vs réel : différences sur stops Mogalef

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #260500 quote
    Madrosat
    Participant
    Master

    Bonjour Nicolas, Yvan

    Voici un trade gagnant en backtest et perdant en réel

    mais si le stop pris en compte n’agissait qu’avec le close il ny aurait pad de différence

    Comment faire

    Ci-joint stratégie sur eur gbp 5 min



    Defparam cumulateorders = false
    ///Bandes de Mogalef d'Eric Lefort
    timeframe (10 minutes)//,updateonclose)
    
    CP=(open+high+low+2*close)/5
    F=LinearRegression[3](CP)
    E=std[7](F)
     
    if barindex<8 then
    Mediane = undefined
    BandeHaute = undefined
    BandeBasse = undefined
     
    Else
    BandeHaute = F+(E*Coef)
    BandeBasse = F-(E*Coef)
     
     
    if F<BandeHaute[1] and F>BandeBasse[1] then
    E=E[1]
    BandeHaute=BandeHaute[1]
    BandeBasse=BandeBasse[1]
    endif
     
    Mediane =(BandeHaute+BandeBasse)/2
    Endif
    Indicator1 = BandeHaute
    Indicator2 =BandeBasse
    //return BandeHaute coloured (255,154,51) as"Mogalef Bande Haute", Mediane coloured (102,0,204) as "Mogalef Mediane", BandeBasse coloured (0,204,255) as "Mogalef Bande Basse"
    
    // TAILLE DES POSITIONS
    n = 1
     
    // PARAMETRES
    // high ratio = few positions
    // AUD/JPY : ratio = 0.5 / SL = 0.8 / TP = 1.2 / Period = 12
    // EUR/JPY : ratio = 0.6 / SL = 1 / TP = 0.8 / Period = 8
    // GBP/JPY : ratio = 0.5 / SL = 0.6 / TP = 1 / Period = 8
    // USD/JPY : ratio = 0.5 / SL = 1 / TP = 0.8 / Period = 12
     
    ratio = 0.5
    period = 6
     
    // HORAIRES
    startTime = 210000
    endTime = 231500
    exitLongTime = 210000
    exitShortTime = 80000
    //notrading = (dayofweek=5 )//AND time>=210000) OR (dayofweek=1 AND time<030000)
    
    
    
      
    if strategyprofit <strategyprofit[1] then//and strategyprofit[1]< strategyprofit[2]then
    notrade = 1
    endif
    if intradaybarindex = 0 then
    notrade = 0
    endif
    if not notrade then
     
    // BOUGIE REFERENCE à StartTime
    if time = startTime THEN
    amplitude = highest[Period](high) - lowest[Period](low)
    ouverture = close
    endif
     
    // LONGS & SHORTS : every day except Fridays
    // entre StartTime et EndTime
    if time >= startTime and time <= endTime and dayOfWeek <> 5 then
    buy n shares at ouverture - amplitude*ratio limit
    sellshort n shares at ouverture + amplitude*ratio limit
    endif
     
    // Stop Loss & Take Profit
    // Stop e target
    //SET STOP PLOSS 25
    SET TARGET PPROFIT 8 //395
     
    //
    //trailing stop function
    //************************************************************************
    
    endif
    if longonmarket and barindex-tradeindex >23 then
    sell at market
    endif
    if shortonmarket and barindex-tradeindex>23 then
    exitshort at market
    endif
    // Exit Time
    //if time = exitLongTime then
    //Set stop ploss 30
    timeframe(default)
    indicator4, indicator5 = CALL "Zigzag Up Down"[0.2](close)
    cvl=longonmarket and close crosses under indicator4
    if cvl then
    sell at market
    endif
    
    cvs = shortonmarket and close crosses over indicator5
    if cvs then
    exitshort at market
    endif
    if onmarket and not onmarket[1] then
    stoploss = indicator2
    endif
    if longonmarket and close > indicator2 and indicator2 > 0 then
    SELL AT stoploss stop
    endif
    //graph indicator2
    set stop ploss 50
    
    Capture-decran-2026-04-24-a-09.41.28-1-scaled.png Capture-decran-2026-04-24-a-09.41.28-1-scaled.png
    #260504 quote
    turame
    Participant
    Master

    Salut Madrosat,

    Impossible de backtester ton code car tu fais appel à l’indicateur Zigzag Up Down que je n’ai pas.

    Je ne vois qu’une seule explication. Je ne connais pas ton spread mais j’imagine que tu as backtesté avec le spread classique de 0.9 sur l’EUR/GBP. Or ton trade est sensé atteindre ton TP dans la nuit où le spread est plus important.

    Donc si ton TP est un cours limite atteint tout juste en démo pendant la nuit, c’est normal que le perde en réel car le spread te désavantage.

    Pour t’en convaincre essaye de rajouter 1 à ton spread actuel sur ton backtest. Il y a fort à parier que le trade soit perdant en démo.

    #260505 quote
    Iván González
    Moderator
    Legend

    Bonjour. Je ne suis pas sûr de comprendre ce que vous voulez…

    Si je comprends bien, vous souhaitez sortir de la position à la clôture si vous êtes en dessous du stop loss ?

    Si c’est ce que vous recherchez, vous ne pouvez pas sortir à la clôture. Vous sortirez toujours à l’ouverture de la barre suivante. Pour vous rapprocher de la clôture, vous pouvez réduire l’unité de temps à quelques secondes, par exemple.

    #260549 quote
    Madrosat
    Participant
    Master

    Bonjour Turame

    Je ne crois pas à ton explication car j’utilise toujours un spread de 2 en démo comme en réelle.


    Bonjour Ivan

    La sortie du trade en réel se fait sur la mèche comment éviter cette sortie sur mèche ( en démo curieusement il n’y a pas de mèche )

    Si l’instruction dit de sortir sur l’ouverture de la barre suivante ( dans la condition de la stratégie . Que dois je changer?)… alors le trade réel devient gagnant comme le trade démo

    Me suis je bien expliqué ??

    Bonne journée à tous

    `Madrosat


    #260590 quote
    turame
    Participant
    Master

    En regardant plus précisément ton image, le graph de ton backtest ne semble pas correspondre avec le graph de ton trade en réel, d’où ma question : es tu certain que tu compares les deux mêmes trades ? Il me semble que non dans ton exemple.

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

Backtest vs réel : différences sur stops Mogalef


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
Madrosat @madrosat Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by turame
4 weeks ago.

Topic Details
Forum: ProOrder : Trading Automatique & Backtests
Language: French
Started: 04/24/2026
Status: Active
Attachments: 1 files
Logo Logo
Loading...