stratégie sur les marchés en temps réel le MTF n’est pas respecter

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #127887 quote
    MagnetikGreen
    Participant
    Average

    Bonjour,

    je construit une stratégie en MTF sur PRT demo IG mais j’ai un soucis, en backtest la stratégie est totalement respecter mais sur les marchés en temps réel le MTF n’est pas respecter…

    Les UT 15mn et 5mn ne sont pas pris en compte du coup le Bot place des ordres  alors que les conditions ne sont pas respecter.

    je ne trouve pas pourquoi…

    Merci pour votre aide.

    Le code lier ci-dessous :

    timeframe(15mn,updateonclose)
    timeq = 0
    if  hausse then
    timeQ = 1
    
    endif
    
    if  baisse then
    timeQ = -1
    
    endif
    
    timeframe(5mn,updateonclose)
    timef = 0
    if  hausse then
    timeF = 1
    
    endif
    
    if  baisse then
    timeF = -1
    
    endif
    
    timeframe(1mn,default)
    ////////////////////////////////////////////////////////////////////
    
    indicator1 = CALL "ICHIMOKU SIGNALS 2 histo"[25, 10]
    c1 = (indicator1 >= 1)
    
    if (c1 and hausse and timeq = 1 and timef =1)or( c1 and hausse and timef = 1 ) then
    ichi = 1
    endif
    
    indicator2 = CALL "ICHIMOKU SIGNALS 2 histo"[25, 10]
    
    c2 = (indicator2 <= -1)
    
    if (c2 and  baisse and timeq = -1 and timef = -1)or( c1 and baisse and timef = -1 )  then
    ichi = -1
    endif
    
    if not longonmarket and ichi = 1 then 
    buy 1 contracts at Market 
    endif
    #128322 quote
    Nicolas
    Keymaster
    Master

    Sauf erreur de ma part, les variables “hausse” et “baisse” ne sont jamais renseignés dans la stratégie, et elles sont pourtant testées à de multiples reprises ?

    #128350 quote
    MagnetikGreen
    Participant
    Average

    Les deux variables sont renseigner mais je ne l’es ai pas inclut dans le bout de code. Tout marche bien mais sauf le MTF qui fonctionne en backtest mais pas en trading en temps réel.

    #128355 quote
    Nicolas
    Keymaster
    Master

    Merci d’inclure l’ensemble du code la prochaine fois, c’est difficile de donner des réponses précises dans les bonnes informations, tu en conviendras.

    Par ailleurs, qu’est ce qui ne fonctionne pas ? Je ne peux pas reproduire, je ne possède pas le code inclut dans ton CALL.

    #128362 quote
    MagnetikGreen
    Participant
    Average
    // HEIHEN HASHI////////////////////////////////////////////////////
    
    //HAturn = 0
    
    IF BarIndex = 0 THEN
    XClose = TotalPrice
    XOpen = (Open + Close) / 2
    ELSE
    XClose = TotalPrice
    XOpen = (XOpen[1] + Xclose[1]) / 2
    ENDIF
    
    // ICHIMOKU/////////////////////////////////////////////////////
    Tenkan = (highest[9](high)+lowest[9](low))/2
    Kijun = (highest[26](high)+lowest[26](low))/2
    SSpanA = (tenkan[26]+kijun[26])/2
    SSpanB = (highest[52](high[26])+lowest[52](low[26]))/2
    
    ////////////////////////////////////////////////////////////////////////
    
    hausse = (SSpanA > SSpanB and xclose >= kijun and xclose > SSpanA and xclose > tenkan and xclose > SSpanA and close > SSpanB and kijun > SSpanA ) or (SSpanA < SSpanB  and xclose >= kijun and xclose > tenkan and open > SSpanA and close > SSpanB and tenkan > SSpanA and kijun > SSpanA)
    
    baisse = (SSpanA < SSpanB and xclose <= kijun and xclose < SSpanA and xclose < tenkan and xclose < SSpanA and close < SSpanB and kijun < SSPanA ) or (SSpanA > SSpanB  and xclose <= kijun and  xclose < tenkan and open < SSpanA and close < SSpanB and tenkan < SSpanA and kijun < SSpanA )
    
    res = 0
    ichi = 0
    //tradeHA = 0
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    
    // ICHIMOKU TREND
    
    if  hausse then
    res = 1
    r = 0
    g = 128
    a = 75
    endif
    
    if  baisse then
    res = -1
    r = 128
    g = 0
    a = 75
    endif
    
    if res = 1 then
    //tradeST = 1
    BACKGROUNDCOLOR(r,g,0,a)
    endif
    
    if res = -1 then
    //tradeST = -1
    BACKGROUNDCOLOR(r,g,0,a)
    endif
    
    if res = 0 then
    r = 0
    g = 0
    a = 0
    BACKGROUNDCOLOR(r,g,0,a)
    endif
    
    

    Le code de l’indicateur appeler dans le bot.

    #128365 quote
    MagnetikGreen
    Participant
    Average

    Le code du bot entier, je l’ai fait pour le Dax en priorité.

    // Définition des paramètres du code
    DEFPARAM CumulateOrders = true// Cumul des positions désactivé
    // Annule tous les ordres en attente et ferme toutes les positions à 0:00, puis empêche toute création d'ordre avant l'heure "FLATBEFORE".
    DEFPARAM FLATBEFORE = 090000
    // Annule tous les ordres en attente et ferme toutes les positions à l'heure "FLATAFTER"
    DEFPARAM FLATAFTER = 183000
    
    timeframe(1mn,default)
    ///////FRACTALS/////////////////////////////////////
    
    Ncandles = 5
    
    // Nombres de bougies de chaque côté de la bougie extrême
    Nside = (Ncandles - 1) / 2
    
    // Définition de la fractale supérieure
    IF high[Nside] >= highest[Ncandles](high) THEN
    //Fup = high[Nside]
    
    ENDIF
    
    // Définition de la fractale inférieure
    IF low[Nside] <= lowest[Ncandles](low) THEN
    //Fdown = low[Nside]
    
    ENDIF
    
    // HEIHEN HASHI////////////////////////////////////////////////////
    
    //HAturn = 0
    
    IF BarIndex = 0 THEN
    XClose = TotalPrice
    XOpen = (Open + Close) / 2
    ELSE
    XClose = TotalPrice
    XOpen = (XOpen[1] + Xclose[1]) / 2
    ENDIF
    
    // ICHIMOKU/////////////////////////////////////////////////////
    Tenkan = (highest[9](high)+lowest[9](low))/2
    Kijun = (highest[26](high)+lowest[26](low))/2
    SSpanA = (tenkan[26]+kijun[26])/2
    SSpanB = (highest[52](high[26])+lowest[52](low[26]))/2
    
    /////////////////GANN NIFTY ////////////////////////////////////////
    long = (sqrt(Dlow(1))+0.166) * (sqrt(Dlow(1))+0.166)
    short = (sqrt(Dhigh(1))-0.167) * (sqrt(Dhigh(1))-0.167)
    
    Res1 = (sqrt(Dlow(1))+0.25) * (sqrt(Dlow(1))+0.25)
    Res1B = (sqrt(Dlow(1))+0.375) * (sqrt(Dlow(1))+0.35)
    Res2 = (sqrt(Dlow(1))+0.5) * (sqrt(Dlow(1))+0.5)
    Res3 = (sqrt(Dlow(1))+1) * (sqrt(Dlow(1))+1)
    res4 = (sqrt(Dlow(1))+0.625) * (sqrt(Dlow(1))+625)
    res5 = (sqrt(Dlow(1))+0.75) * (sqrt(Dlow(1))+0.75)
    res6= (sqrt(Dlow(1))+0.875) * (sqrt(Dlow(1))+0.875)
    
    Sup1 = (sqrt(Dhigh(1))-0.25) * (sqrt(Dhigh(1))-0.25)
    Sup1B = (sqrt(Dhigh(1))-0.375) * (sqrt(Dhigh(1))-0.375)
    Sup2 = (sqrt(Dhigh(1))-0.5) * (sqrt(Dhigh(1))-0.5)
    Sup3 = (sqrt(Dhigh(1))-1) * (sqrt(Dhigh(1))-1)
    sup4 = (sqrt(Dlow(1))-0.625) * (sqrt(Dlow(1))-625)
    sup5 = (sqrt(Dlow(1))-0.75) * (sqrt(Dlow(1))-0.75)
    sup6= (sqrt(Dlow(1))-0.875) * (sqrt(Dlow(1))-0.875)
    //////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////
    // VAIRABLES
    
    hausse = (SSpanA > SSpanB and xclose >= kijun and xclose > SSpanA and xclose > tenkan and xclose > SSpanA and close > SSpanB and kijun > SSpanA ) or (SSpanA < SSpanB  and xclose >= kijun and xclose > tenkan and open > SSpanA and close > SSpanB and tenkan > SSpanA and kijun > SSpanA)
    
    baisse = (SSpanA < SSpanB and xclose <= kijun and xclose < SSpanA and xclose < tenkan and xclose < SSpanA and close < SSpanB and kijun < SSPanA ) or (SSpanA > SSpanB  and xclose <= kijun and  xclose < tenkan and open < SSpanA and close < SSpanB and tenkan < SSpanA and kijun < SSpanA )
    
    ichi = 0
    //HAtrade = 0
    //res = 0
    // CONDITIONS
    timeframe(15mn,updateonclose)
    timeq = 0
    if  hausse then
    timeQ = 1
    
    endif
    
    if  baisse then
    timeQ = -1
    
    endif
    
    timeframe(5mn,updateonclose)
    timef = 0
    if  hausse then
    timeF = 1
    
    endif
    
    if  baisse then
    timeF = -1
    
    endif
    ///////////////////////////////////////////////////////////////////////////////
    timeframe(1mn,default)
    
    indicator1 = CALL "ICHIMOKU SIGNALS 2 histo"[25, 10]
    c1 = (indicator1 >= 1)
    
    if (c1 and hausse and timeq = 1 and timef =1)or( c1 and hausse and timef = 1 ) then
    ichi = 1
    endif
    
    indicator2 = CALL "ICHIMOKU SIGNALS 2 histo"[25, 10]
    
    c2 = (indicator2 <= -1)
    
    if (c2 and  baisse and timeq = -1 and timef = -1)or( c1 and baisse and timef = -1 )  then
    ichi = -1
    endif
    
    //////////////////////VOLUME //////////////////////////////////////
    EM = ExponentialAverage[14](Volume)
    VL = Volume
    AVL = (VL > EM)
    //c2 = em crosses under VL
    
    ////////////////////////////////////////////////////////////////////////
    
    // Conditions pour ouvrir une position acheteuse
    IF NOT LongOnMarket AND ichi = 1 and AVL  THEN
    BUY 1 CONTRACTS AT MARKET
    //set target profit tp
    set stop %loss 1
    ENDIF
    
    //
    // Conditions pour fermer une position acheteuse
    //if longonmarket and close crosses under kijun then
    //sell at market
    //endif
    //
    // Conditions pour ouvrir une position en vente à découvert
    IF NOT ShortOnMarket AND ichi = -1 and AVL  THEN
    SELLSHORT 1 contracts AT MARKET
    //set target profit 10
    set stop %loss 1
    ENDIF
    
    
    // Conditions pour fermer une position en vente à découvert
    if shortonmarket and close crosses over SHORT or close crosses under SHORT then //  GANN NIFTY AUTO
    exitshort at market
    endif
    if shortonmarket and close crosses over long or close crosses under long then
    exitshort at market
    endif
    if shortonmarket and close crosses over res1 or close crosses under res1 then
    exitshort at market
    endif
    if shortonmarket and close crosses over res1B or close crosses under res1B then
    exitshort at market
    endif
    if shortonmarket and close crosses over res2 or close crosses under res2 then
    exitshort at market
    endif
    if shortonmarket and close crosses over res3 or close crosses under res3 then
    exitshort at market
    endif
    if shortonmarket and close crosses over res4 or close crosses under res4 then
    exitshort at market
    endif
    if shortonmarket and close crosses over res5 or close crosses under res5 then
    exitshort at market
    endif
    if shortonmarket and close crosses over res6 or close crosses under res6 then
    exitshort at market
    endif
    if shortonmarket and close crosses over sup1 or close crosses under sup1 then
    exitshort at market
    endif
    if shortonmarket and close crosses over sup1B or close crosses under sup1B then
    exitshort at market
    endif
    if shortonmarket and close crosses over sup2 or close crosses under sup2 then
    exitshort at market
    endif
    if shortonmarket and close crosses over sup3 or close crosses under sup3 then
    exitshort at market
    endif
    if shortonmarket and close crosses over sup4 or close crosses under sup4 then
    exitshort at market
    endif
    if shortonmarket and close crosses over sup5 or close crosses under sup5 then
    exitshort at market
    endif
    if shortonmarket and close crosses over sup6 or close crosses under sup6 then
    exitshort at market
    endif
    
    
    if longonmarket and close crosses over SHORT or close crosses under SHORT then //  GANN NIFTY AUTO
    sell at market
    endif
    if longonmarket and close crosses over long or close crosses under long then
    sell at market
    endif
    if longonmarket and close crosses over res1 or close crosses under res1 then
    sell at market
    endif
    if longonmarket and close crosses over res1B or close crosses under res1B then
    sell at market
    endif
    if longonmarket and close crosses over res2 or close crosses under res2 then
    sell at market
    endif
    if longonmarket and close crosses over res3 or close crosses under res3 then
    sell at market
    endif
    if longonmarket and close crosses over res4 or close crosses under res4 then
    sell at market
    endif
    if longonmarket and close crosses over res5 or close crosses under res5 then
    sell at market
    endif
    if longonmarket and close crosses over res6 or close crosses under res6 then
    sell at market
    endif
    if longonmarket and close crosses over sup1 or close crosses under sup1 then
    sell at market
    endif
    if longonmarket and close crosses over sup1B or close crosses under sup1B then
    sell at market
    endif
    if longonmarket and close crosses over sup2 or close crosses under sup2 then
    sell at market
    endif
    if longonmarket and close crosses over sup3 or close crosses under sup3 then
    sell at market
    endif
    if longonmarket and close crosses over sup4 or close crosses under sup4 then
    sell at market
    endif
    if longonmarket and close crosses over sup5 or close crosses under sup5 then
    sell at market
    endif
    if longonmarket and close crosses over sup6 or close crosses under sup6 then
    sell at market
    endif
    
    
    // Stops et objectifs : entrez vos stops et vos objectifs ici
    
    // FRACTALS ///////////////////////////////////////////////////////////////
    
    //trailing stop function
    trailingstart = 1 //trailing will start @trailinstart points profit
    trailingstep = 1 //trailing step to move the "stoploss"
    
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
    
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
    
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = newSL-trailingstep*pipsize
    ENDIF
    ENDIF
    
    
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    
    #128375 quote
    Nicolas
    Keymaster
    Master

    J’ai scindé le sujet pour en créer un nouveau dédié à ton problème. Je vais tâcher de comprendre, je te répondrai ici.

    #128376 quote
    MagnetikGreen
    Participant
    Average

    Ok merci Nicolas. 🙂

    #128378 quote
    Nicolas
    Keymaster
    Master

    Pourrais-tu m’indiquer par une copie d’écran comparative pourquoi tu penses qu’un ordre n’est pas à sa place stp ? et avec une explication détaillée vis à vis de la stratégie. Je comprendrai nettement plus vite, merci 🙂

    #128388 quote
    MagnetikGreen
    Participant
    Average

    Les deux trades sur le screen ont été fait par le bot en temps réel sauf qu’il n’aurait jamais du exister car sur l’UT 5mn la variable hausse n’est pas égale à 1 . Le bot sauf erreur de ma part doit placer un ordre au marché uniquement si  hausse  = 1 ou baisses = -1  sur UT5mn et UT1ln minimum. Sur le screen on peut voir que sur le backtest les trade ne sont pas fait. j’espère avoir été assez précis. 🙂

    Capture-20.png Capture-20.png
    #128408 quote
    MagnetikGreen
    Participant
    Average

    J’ai remarquer que le code de l’indicateur ichimoku histo n’est pas complet. Voila le code complet :

    // HEIHEN HASHI////////////////////////////////////////////////////
    
    //HAturn = 0
    
    IF BarIndex = 0 THEN
    XClose = TotalPrice
    XOpen = (Open + Close) / 2
    ELSE
    XClose = TotalPrice
    XOpen = (XOpen[1] + Xclose[1]) / 2
    ENDIF
    
    // ICHIMOKU/////////////////////////////////////////////////////
    Tenkan = (highest[9](high)+lowest[9](low))/2
    Kijun = (highest[26](high)+lowest[26](low))/2
    SSpanA = (tenkan[26]+kijun[26])/2
    SSpanB = (highest[52](high[26])+lowest[52](low[26]))/2
    
    ////////////////////////////////////////////////////////////////////////
    
    hausse = (SSpanA > SSpanB and xclose >= kijun and xclose > SSpanA and xclose > tenkan and xclose > SSpanA and close > SSpanB and kijun > SSpanA ) or (SSpanA < SSpanB  and xclose >= kijun and xclose > tenkan and open > SSpanA and close > SSpanB and tenkan > SSpanA and kijun > SSpanA)
    
    baisse = (SSpanA < SSpanB and xclose <= kijun and xclose < SSpanA and xclose < tenkan and xclose < SSpanA and close < SSpanB and kijun < SSPanA ) or (SSpanA > SSpanB  and xclose <= kijun and  xclose < tenkan and open < SSpanA and close < SSpanB and tenkan < SSpanA and kijun < SSpanA )
    
    res = 0
    ichi = 0
    //tradeHA = 0
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    
    // ICHIMOKU TREND
    
    if  hausse then
    res = 1
    r = 0
    g = 128
    a = 75
    endif
    
    if  baisse then
    res = -1
    r = 128
    g = 0
    a = 75
    endif
    
    if res = 1 then
    //tradeST = 1
    BACKGROUNDCOLOR(r,g,0,a)
    endif
    
    if res = -1 then
    //tradeST = -1
    BACKGROUNDCOLOR(r,g,0,a)
    endif
    
    if res = 0 then
    r = 0
    g = 0
    a = 0
    BACKGROUNDCOLOR(r,g,0,a)
    endif
    /////////////////////////////////////////////////////////////////////////////////
    
    
    if ((open < kijun and close > Kijun) or (open < kijun and close > tenkan) or (xclose crosses over Tenkan) or (xclose crosses over SSpanB) or (xclose crosses over SSpanA)) and res = 1 then
    ichi = 1
    r = 62
    g = 160
    b = 251
    DRAWARROWUP(barindex, low - pips )COLOURED(r,g,b)
    endif
    
    if ((open > kijun and close < Kijun) or (open > kijun and close < tenkan) or (xclose crosses under Tenkan) or (xclose crosses under SSpanB) or (xclose crosses under SSpanA) ) and res = -1 then
    ichi = -1
    r = 255
    g = 113
    b = 0
    DRAWARROWDOWN(barindex, high + pips )COLOURED(r,g,b)
    endif
    
    ///////////////////////////////////////////////////////////////////////////////////
    
    RETURN  ichi coloured(r,g,b) style(HISTOGRAM)
    #128780 quote
    MagnetikGreen
    Participant
    Average

    Bonjour,

    je relance le sujet, j’aimerai savoir si c’est un problème lier à PRT demo IG ou si j’ai fais une erreur de code ?

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

stratégie sur les marchés en temps réel le MTF n’est pas respecter


ProOrder : Trading Automatique & Backtests

New Reply
Author
author-avatar
MagnetikGreen @moustiks Participant
Summary

This topic contains 11 replies,
has 2 voices, and was last updated by MagnetikGreen
5 years, 10 months ago.

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