Problème multiframe sur 3 unités de temps

Viewing 12 posts - 16 through 27 (of 27 total)
  • Author
    Posts
  • #132860 quote
    Fantasio2020
    Participant
    Senior

    Merci Nicolas,

    le code se comporte en effet bien différemment!

    je vais continuer à conditionner pour éviter les faux signaux.

     

    Grand Merci

    #133071 quote
    Fantasio2020
    Participant
    Senior

    Merci Nicolas,

    Fonctionne très bien pour chaque UT.

    La stratégie est maintenant Opérationnelle et Fonctionnelle…

    Slts

    #133081 quote
    Nicolas
    Keymaster
    Master

    Bonne nouvelle, et bonne continuation ! 😉

    #133108 quote
    Madrosat
    Participant
    Master

    Bonjour Fantasio peux tu montrer ton code rectifié entièrement que je comprenne bien

    #133202 quote
    Fantasio2020
    Participant
    Senior
    timeframe(15 minute)
    MMA100A15 = ExponentialAverage[100](close)
    MMA300A15 = ExponentialAverage[300](close)
    MMA600A15 = ExponentialAverage[600](close)
    MMA1000A15 = ExponentialAverage[1000](Close)
    BuyConditionA = (Close > MMA100A15) and (Close > MMA300A15) and (Close > MMA600A15) and (Close > MMA1000A15)
    if BuyConditionA then
    xA = BuyConditionA
    endif
    
    //déclare la stratégie dans l'UT 5 minutes
    timeframe(5 minute)
    MMA100A5 = ExponentialAverage[100](close)
    MMA300A5 = ExponentialAverage[300](close)
    MMA600A5 = ExponentialAverage[600](close)
    MMA1000A5 = ExponentialAverage[1000](Close)
    BuyConditionB = (Close > MMA100A5) and (Close > MMA300A5) and (Close > MMA600A5) and (Close > MMA1000A5)
    if BuyConditionB then
    yA = BuyConditionB
    endif

    Voici un morceau du code rectifié…. et de cette manière, les variable sont bien lues dans Chaque UT Correspondante 🙂

    De cette manière tu obtiens les convergences recherchées.

    Je vais faire tourner la stratégie un moment en réel pour m’assurer que ça me donne les mêmes résultat qu’en BackTest….le WALKFORWARD fonctionne bien de 10/80 à 50/50…donc il n’y a pas de raison que ça n’aille pas….

    je dois intégrer quelques conditions pour améliorer mon ratio Gain/Perte

    je vous tiendrez informé.

    Slts

    #166615 quote
    ginko
    Participant
    Average

    PRT V11 affiche un message d’erreur explicite dans ce cas. Toutes les variables définies dans un timeframe ne peuvent être redéfinies dans un autre timeframe

    Le code total d’origine de fantasio ici https://www.prorealcode.com/topic/probleme-multiframe-sur-3-unites-de-temps/#post-132464 devient par exemple

    // Définition des paramètres du code
    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
    //DEFPARAM FLATBEFORE = 091500
    //DEFPARAM FLATAFTER = 154500
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
     
    //Indicateurs de tendance
    Pivot = (DHigh(1) + DLow(1) + DClose(1) + DOpen(0))/4
    //Indicateurs de prise de positions
     
    //Position acheteuse
    //declare the strategy on the 15 minutes timeframe
    timeframe(15 minute, updateonclose)
    MMA100M15 = (ExponentialAverage[100](close))
    MMA300M15 = (ExponentialAverage[300](close))
    MMA600M15 = (ExponentialAverage[600](close))
    MMA1000M15 = (ExponentialAverage[1000](close))
    IndM15 = RSI[7](Close)
    xM15 = 0.1 * (IndM15 - 50)
    yM15 = (EXP (2 * xM15) - 1) / (EXP (2 * xM15) + 1)
    zM15 = 50 * (yM15 + 1)
    TimeM15aa = Close > MMA100M15
    TimeM15ab = Close > MMA300M15
    TimeM15ac = Close > MMA600M15
    TimeM15ad = Close > MMA1000M15
    TimeM15ae = zM15 < 38.2
    buyconditionM15 = (TimeM15aa and TimeM15ab and TimeM15ac and TimeM15ad and TimeM15ae)
     
    //declare the strategy on the 5 minutes timeframe
    timeframe(5 minute, updateonclose)
    MMA100M5 = (ExponentialAverage[100](close))
    MMA300M5 = (ExponentialAverage[300](close))
    MMA600M5 = (ExponentialAverage[600](close))
    MMA1000M5 = (ExponentialAverage[1000](close))
    IndM5 = RSI[7](Close)
    xM5 = 0.1 * (IndM5 - 50)
    yM5 = (EXP (2 * xM5) - 1) / (EXP (2 * xM5) + 1)
    zM5 = 50 * (yM5 + 1)
    TimeM5aa = Close > MMA100M5
    TimeM5ab = Close > MMA300M5
    TimeM5ac = Close > MMA600M5
    TimeM5ad = Close > MMA1000M5
    TimeM5ae = zM5 < 38.2
    buyconditionM5 = (TimeM5aa and TimeM5ab and TimeM5ac and TimeM5ad and TimeM5ae)
     
    //declare the strategy on the 1 minutes Default
    timeframe(1 minute, Default)
    MMA100Dft = (ExponentialAverage[100](close))
    MMA300Dft = (ExponentialAverage[300](close))
    MMA600Dft = (ExponentialAverage[600](close))
    MMA1000Dft = (ExponentialAverage[1000](close))
    IndDft = RSI[7](Close)
    xDft = 0.1 * (IndDft - 50)
    yDft = (EXP (2 * xDft) - 1) / (EXP (2 * xDft) + 1)
    zDft = 50 * (yDft + 1)
    TimeM1aa = Close > Pivot
    TimeM1ab = Close > MMA100Dft
    TimeM1ac = Close > MMA300Dft
    TimeM1ad = Close > MMA600Dft
    TimeM1ae = Close > MMA1000Dft
    TimeM1af = zDft < 38.2
    buyconditiondft = (TimeM1aa and TimeM1ab and TimeM1ac and TimeM1ad and TimeM1ae and TimeM1af)
    if (buyconditionM15 and buyconditionM5 and buyconditionDft) and not daysForbiddenEntry then
    buy 0.3 share at market
    endif
     
    //Position Vendeuse
    //declare the strategy on the 15 minutes timeframe
    timeframe(15 minute, updateonclose)
    TimeM15va = Close < MMA100M15
    TimeM15vb = Close < MMA300M15
    TimeM15vc = Close < MMA600M15
    TimeM15vd = Close < MMA1000M15
    TimeM15ve = zM15 > 61.8
    sellconditionM15 = (TimeM15va and TimeM15vb and TimeM15vc and TimeM15vd and TimeM15ve)
     
    //declare the strategy on the 5 minutes timeframe
    timeframe(5 minute, updateonclose)
    TimeM5va = Close < MMA100M5
    TimeM5vb = Close < MMA300M5
    TimeM5vc = Close < MMA600M5
    TimeM5vd = Close < MMA1000M5
    TimeM5ve = zM5 > 61.8
    sellconditionM5 = (TimeM5va and TimeM5vb and TimeM5vc and TimeM5vd and TimeM5ve)
     
    //declare the strategy on the 1 minutes Default
    timeframe(1 minute, Default)
    TimeM1va = Close < Pivot
    TimeM1vb = Close < MMA100Dft
    TimeM1vc = Close < MMA300Dft
    TimeM1vd = Close < MMA600Dft
    TimeM1ve = Close < MMA1000Dft
    TimeM1vf = zDft > 61.8
    sellconditionDft = (TimeM1va and TimeM1vb and TimeM1vc and TimeM1vd and TimeM1ve and TimeM1vf)
    
    
    if (sellconditionM15 and sellconditionM5 and sellconditionDft) and not daysForbiddenEntry then
    sellshort 0.3 share at market
    endif
     
    //************************************************************************
    //Stop Loss & Trailing function
    SET STOP LOSS 27
    trailingstart = 27 //trailing will start @trailinstart points profit
    trailingstep = 9 //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
     
    Graphonprice pivot
    Graphonprice MMA100M15
    Graphonprice MMA300M15
    Graphonprice MMA600M15
    Graphonprice MMA1000M15
    
    
    PRTv11ErreurMTF.jpg PRTv11ErreurMTF.jpg
    #166622 quote
    ginko
    Participant
    Average

    Cela dit, je pense avoir trouvé un problème de calcul car j’ai fait un indicateur qui calcule les moyennes mobiles en timeframe 15 minutes et 5 minutes sur le graphe, et les valeurs ne correspondent pas avec celles du back-test. Aucun problème pour l’EMA 100 mais des problèmes sur les calculs d’EMA sur ces périodes  plus longues. Pour faire simple j’ai fait une stratégie très courte et un indicateur très court aussi qui permet de montrer le problème de calcul entre la stratégie PRT et l’indicateur

    timeframe(15 minute)
    MMA100M15 = (ExponentialAverage[100](close))
    MMA600M15 = (ExponentialAverage[600](close))
    
    timeframe(5 minute)
    MMA100M5 = (ExponentialAverage[100](close))
    MMA600M5 = (ExponentialAverage[600](close))
    
    timeframe(1 minute)
    MMA100M1 = (ExponentialAverage[100](close))
    MMA600M1 = (ExponentialAverage[600](close))
    
    return MMA100M15 as "iEMA100M15", MMA600M15 as "iEMA600M15", MMA100M5 as "iEMA100M5", MMA600M5 as "iEMA600M5", MMA100M1 as "iEMA100M1", MMA600M1 as "iEMA600M1"
    

    Et sur la stratégie,

    // Définition des paramètres du code
    DEFPARAM CumulateOrders = False // Cumul des positions désactivé
    
    timeframe(15 minute)
    MMA100M15 = (ExponentialAverage[100](close))
    MMA600M15 = (ExponentialAverage[600](close))
    
    timeframe(5 minute)
    MMA100M5 = (ExponentialAverage[100](close))
    MMA600M5 = (ExponentialAverage[600](close))
    
    timeframe(1 minute)
    MMA100M1 = (ExponentialAverage[100](close))
    MMA600M1 = (ExponentialAverage[600](close))
    
    Graphonprice MMA100M15 as "sEMA100M15"
    Graphonprice MMA600M15 as "sEMA600M15"
    
    Graphonprice MMA100M5 as "sEMA100M5"
    Graphonprice MMA600M5 as "sEMA600M5"
    
    Graphonprice MMA100M1 as "sEMA100M1"
    Graphonprice MMA600M1 as "sEMA600M1"
    
    VosConditions = 0
    
    // généré automatiquement par PRT
    // Conditions pour ouvrir une position acheteuse
    IF NOT LongOnMarket AND VosConditions THEN
    BUY 1 CONTRACTS AT MARKET
    ENDIF
    
    // Conditions pour fermer une position acheteuse
    If LongOnMarket AND VosConditions THEN
    SELL AT MARKET
    ENDIF
    
    // Conditions pour ouvrir une position en vente à découvert
    IF NOT ShortOnMarket AND VosConditions THEN
    SELLSHORT 1 CONTRACTS AT MARKET
    ENDIF
    
    // Conditions pour fermer une position en vente à découvert
    IF ShortOnMarket AND VosConditions THEN
    EXITSHORT AT MARKET
    ENDIF
    
    // Stops et objectifs : entrez vos stops et vos objectifs ici
    

     

    les chiffres sont différérents pour les EMA de 600 prériodes en UT M5 et UT M15. Le backtest prend toutes les dates affichées (pas de  différence sur la date de début par exemple).

    Nicolas tu confirmes le problème ?

    difference_StrategieEtIndicateurMTF.jpg difference_StrategieEtIndicateurMTF.jpg difference_StrategieEtIndicateurMTF1.jpg difference_StrategieEtIndicateurMTF1.jpg
    #166625 quote
    ginko
    Participant
    Average
    #166634 quote
    ginko
    Participant
    Average

    J’ai trouvé le problème qui me semble être un bug dans le mode timeframe d’un indicateur PRT à première vue, pour avoir un calcul qui se rapproche de la réalité sur le graphique 1 minute, il faut afficher beaucoup d’unités (beaucoup plus qu’il n’en faudrait a priori pour calculer une EMA de 600 en UT 15 minutes sur un graphique 1 minute). même avec 20 k unités affichées en 1 minute, le calcul de l’EMA 600 sur un timeframe de 15 minutes est faux…

    J’ai posté dans le forum anglais https://www.prorealcode.com/topic/multi-timeframe-mtf-indicators-for-prorealtime/page/4/#post-166630

    Y-a-t-il une explication à ce problème ?

    difference_StrategieEtIndicateurMTF3-1.jpg difference_StrategieEtIndicateurMTF3-1.jpg
    #166644 quote
    Nicolas
    Keymaster
    Master
    EMA utilise la valeur EMA précédente avec un facteur de pondération pour calculer en continu la nouvelle valeur, donc une décroissance peut se produire si vous démarrez le calcul plus tôt ou plus tard, et c'est ce que vous observez ici. Si j'utilise 30k unités, j'obtiens les mêmes résultats sur la barre actuelle.
    #166664 quote
    ginko
    Participant
    Average

    Oui je suis d’accord sur le principe de l’EMA mais la différence est assez sérieuse.
    Ca veut dire qu’il faut se méfier des calculs récursifs longs entre indicateurs et stratégie de back test sur PRT.

    #175841 quote
    wtangsiri
    Participant
    Junior

    Bonjour Fantasio

    J’ai vu votre demande auprès de Nicolas, et je m’aperçois que je recherche quelque chose qui est très similaire et je me suis dit que peut-être, vous pourriez m’aider :

    Je recherche un programme qui permet de collecter le RSI en timeframe 1mn, 5mn, et 15mn et d’afficher le résultat sur un petit coin d’écran

    Auriez vous une idée ?

    Merci pour votre retour

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

Problème multiframe sur 3 unités de temps


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
Summary

This topic contains 26 replies,
has 3 voices, and was last updated by wtangsiri
4 years, 6 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 05/20/2020
Status: Active
Attachments: 11 files
Logo Logo
Loading...