Affichage EMA 200 sur UT 1,5 et 15 Mn

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #197446 quote
    wtangsiri
    Participant
    Junior

    Bonjour Nicolas,

    J’ai besoin de votre service svp

    J’ai écrit un programme pour afficher le cours d’un actif (ici le NQ) en UT 1Mn, 5 Mn, et 15 Mn, avec EMA 200 et SMA 50
    Le programme m’affiche N/D, alors, j’essaye d’augmenter l’instruction CalculateOnLastBars à 10000, c’est même résultat, mais lorsque j’essaye de diminuer la valeur de EMA (50 au lieu de 200) et là, ça marche parfaitement
    je souhaitre savoir d’où vient ce problème (lack of memory ?)
    Voici le code mon programme

    DefParam DrawOnLastBarOnly = True
    DefParam CalculateOnLastBars=10000

     

    TimeFrame(15 minutes)
    //—–EMA en UT 5 mn—–
    My15MnEMA200 = Average[200,1](close)
    My15MnSMA50 = Average[50,0](close)

    TimeFrame(5 minutes)
    //—–EMA en UT 5 mn—–
    My5MnEMA200 = Average[200,1](close)
    My5MnSMA50 = Average[50,0](close)

     

    TimeFrame(1 minute, Default)
    //—– Calcul du VWAP —–
    d = max(1, intradaybarindex)
    MyVwap = SUMMATION[d](volume*typicalprice)/SUMMATION[d](volume)
    MyVwapRounded = Round(MyVwap, 2)

    //—–EMA en UT 1 mn—–
    My1MnEMA200 = Average[200,1](close)
    My1MnSMA50 = Average[50,0](close)

    MyPrice = Close
    MyPriceRounded = Round(MyPrice, 2)

    //————- Les calculs commencent ici ————–
    MyDiffPriceVwap = MyPriceRounded – MyVwapRounded

    My15MnAboveEMA200 = Close > My15MnEMA200
    My15MnAboveSMA50 = Close > My15MnSMA50

    My5MnAboveEMA200 = Close > My5MnEMA200
    My5MnAboveSMA50 = Close > My5MnSMA50

    My1MnAboveEMA200 = Close > My1MnEMA200
    My1MnAboveSMA50 = Close > My1MnSMA50

    //============= DEBUT PROGRAMME =============

    //—–Affichage Prix Actuel—–

    DrawText(“Vwap : #MyVwapRounded# “, barindex-61, 9.0, SansSerif, Bold, 12) coloured(0,0,0)
    DrawText(“Prix : #MyPrice# “, barindex-48, 9.0, SansSerif, Standard, 12) coloured(0,0,0)
    //DrawText(“Vwap : #MyVwapRounded# “, barindex-48, 9.0, SansSerif, standard, 12)
    DrawText(“Diff : #MyDiffPriceVwap# “, barindex-36, 9.0, SansSerif, standard, 12)

    DrawText(“EMA200 SMA50 “, barindex-39, 7.0, dialog, standard,12)

    DrawText(“15 Minutes “, barindex-60, 2.0, dialog, standard,12)
    DrawText(“5 Minutes “, barindex-60, 1.0, dialog, standard,12)
    DrawText(“1 Minute “, barindex-60, 0.0, dialog, standard,12)

     

    //—–Affichage Ligne “15 Minutes”—–
    If My15MnAboveEMA200 then
    DrawText(“#My15MnEMA200#”, barindex-45, 2.0, dialog, standard,12) coloured(102,255,0) //Point Vert
    Else
    DrawText(“#My15MnEMA200#”, barindex-45, 2.0, dialog, standard,12) coloured(255,0,0)
    Endif
    If My15MnAboveSMA50 then
    DrawText(“#My15MnSMA50#”, barindex-35, 2.0, dialog, standard,12) coloured(102,255,0) //Point Vert
    Else
    DrawText(“#My15MnSMA50#”, barindex-35, 2.0, dialog, standard,12) coloured(255,0,0)
    Endif

    //—–Affichage Ligne “5 Minutes”—–
    If My5MnAboveEMA200 then
    DrawText(“#My5MnEMA200#”, barindex-45, 1.0, dialog, standard,12) coloured(102,255,0)
    Else
    DrawText(“#My5MnEMA200#”, barindex-45, 1.0, dialog, standard,12) coloured(255,0,0)
    Endif
    If My5MnAboveSMA50 then
    DrawText(“#My5MnSMA50#”, barindex-35, 1.0, dialog, standard,12) coloured(102,255,0)
    Else
    DrawText(“#My5MnSMA50#”, barindex-35, 1.0, dialog, standard,12) coloured(255,0,0)
    Endif

    //—–Affichage Ligne “1 Minute”—–
    If My1MnAboveEMA200 then
    DrawText(“#My1MnEMA200#”, barindex-45, 0.0, dialog, standard,12) coloured(102,255,0) //Point Vert
    Else
    DrawText(“#My1MnEMA200#”, barindex-45, 0.0, dialog, standard,12) coloured(255,0,0) //Point Rouge
    Endif
    If My1MnAboveSMA50 then
    DrawText(“#My1MnSMA50#”, barindex-35, 0.0, dialog, standard,12) coloured(102,255,0) //Point Vert
    Else
    DrawText(“#My1MnSMA50#”, barindex-35, 0.0, dialog, standard,12) coloured(255,0,0) //Point Rouge
    Endif

    //—–Affichage des échelles—–
    Return -3 Coloured(0,0,0,0), 10 Coloured(0,0,0,0)

     

    Je vous remercie beaucoup
    Bien cordialement

    #197456 quote
    fifi743
    Participant
    Master

    bonjour,

    as tu 1 K ou 10 K  unitées ?

    druby and wtangsiri thanked this post
    #197457 quote
    druby
    Participant
    New

    BJ…    Code bien formaté.

    Nécessite un réglage de 2500 unités, sur le mien, avant que 15 minutes ne commencent à donner des valeurs.

    TF15m + EMA200 = 15 x 200 = 3000 barre . Même si votre graphique par défaut est de 1 minute.

    Aussi à partir des lignes de code 47-50 avec #…variable…# et la variable n’est pas la même doit être #variable#

    Utilisez-vous V11, vous pouvez désormais “ancrer” dessiner des objets tels que du texte.

    Remarque: commenté “Calculer OnLastBars = 10000” Qu’est-ce que c’était avant de le changer et quelles étaient les unités définies.

     

     

    DefParam DrawOnLastBarOnly = True
    //DefParam CalculateOnLastBars=10000
    
     
    
    TimeFrame(15 minutes)
    //—-EMA en UT 5 mn—-
    My15MnEMA200 = Average[200,1](close)
    My15MnSMA50 = Average[50,0](close)
    
    TimeFrame(5 minutes)
    //—-EMA en UT 5 mn—-
    My5MnEMA200 = Average[200,1](close)
    My5MnSMA50 = Average[50,0](close)
    
     
    
    TimeFrame(1 minute, Default)
    //—- Calcul du VWAP —-
    d = max(1, intradaybarindex)
    MyVwap = SUMMATION[d](volume*typicalprice)/SUMMATION[d](volume)
    MyVwapRounded = Round(MyVwap, 2)
    
    //—-EMA en UT 1 mn—-
    My1MnEMA200 = Average[200,1](close)
    My1MnSMA50 = Average[50,0](close)
    
    MyPrice = Close
    MyPriceRounded = Round(MyPrice, 2)
    
    //————- Calculations start here ————-
    MyDiffPriceVwap = MyPriceRounded - MyVwapRounded
    
    My15MnAboveEMA200 = Close > My15MnEMA200
    My15MnAboveSMA50 = Close > My15MnSMA50
    
    My5MnAboveEMA200 = Close > My5MnEMA200
    My5MnAboveSMA50 = Close > My5MnSMA50
    
    My1MnAboveEMA200 = Close > My1MnEMA200
    My1MnAboveSMA50 = Close > My1MnSMA50
    
    //============= DEBUT PROGRAMME =============
    
    //—-Current Price Display—-
    
    DrawText ("Vwap: #MyVwapRounded#", barindex-61, 9.0, SansSerif, Bold, 12) coloured (0,0,0)
    DrawText ("Prix: #MyPrice#", barindex-48, 9.0, SansSerif, Standard, 12)  coloured (0,0,0) 
    //DrawText ("Vwap: #MyVwapRounded#", barindex-48, 9.0, SansSerif, standard, 12)
    DrawText ("Diff: #MyDiffPriceVwap#", barindex-36, 9.0, SansSerif, standard, 12)
    
    DrawText("EMA200 SMA50 ", barindex-39, 7.0, dialog, standard,12)
    
    DrawText("15 Minutes ", barindex-60, 2.0, dialog, standard,12)
    DrawText("5 Minutes ", barindex-60, 1.0, dialog, standard,12)
    DrawText("1 Minute ", barindex-60, 0.0, dialog, standard,12)
    
     
    
    //—-Affichage Ligne "15 Minutes"—-
    If My15MnAboveEMA200 then
    DrawText("#My15MnEMA200#", barindex-45, 2.0, dialog, standard,12) coloured(102,255,0) //Point Vert
    Else
    DrawText("#My15MnEMA200#", barindex-45, 2.0, dialog, standard,12) coloured(255,0,0)
    Endif
    If My15MnAboveSMA50 then
    DrawText("#My15MnSMA50#", barindex-35, 2.0, dialog, standard,12) coloured(102,255,0) //Point Vert
    Else
    DrawText("#My15MnSMA50#", barindex-35, 2.0, dialog, standard,12) coloured(255,0,0)
    Endif
    
    //—-Affichage Ligne "5 Minutes"—-
    If My5MnAboveEMA200 then
    DrawText("#My5MnEMA200#", barindex-45, 1.0, dialog, standard,12) coloured(102,255,0)
    Else
    DrawText("#My5MnEMA200#", barindex-45, 1.0, dialog, standard,12) coloured(255,0,0)
    Endif
    If My5MnAboveSMA50 then
    DrawText("#My5MnSMA50#", barindex-35, 1.0, dialog, standard,12) coloured(102,255,0)
    Else
    DrawText("#My5MnSMA50#", barindex-35, 1.0, dialog, standard,12) coloured(255,0,0)
    Endif
    
    //—-Affichage Ligne "1 Minute"—-
    If My1MnAboveEMA200 then
    DrawText("#My1MnEMA200#", barindex-45, 0.0, dialog, standard,12) coloured(102,255,0) //Point Vert
    Else
    DrawText("#My1MnEMA200#", barindex-45, 0.0, dialog, standard,12) coloured(255,0,0) //Point Rouge
    Endif
    If My1MnAboveSMA50 then
    DrawText("#My1MnSMA50#", barindex-35, 0.0, dialog, standard,12) coloured(102,255,0) //Point Vert
    Else
    DrawText("#My1MnSMA50#", barindex-35, 0.0, dialog, standard,12) coloured(255,0,0) //Point Rouge
    Endif
    
    //—-Display scales—- 
    Return -3 Coloured(0,0,0,0), 10 Coloured(0,0,0,0)
    wtangsiri thanked this post
    #197459 quote
    wtangsiri
    Participant
    Junior

    Vous êtes tous formidables !!!!!

    j’ai mis 100 unités seulement, et c’est pour cela que ça ne fonctionne pas, car passez d’unités pour calculer EMA 200 en UT 15 mn
    Maintenant, j’ai mis 3000 unités, et c’est à merveille !
    Merci beaucoup les gars !

    PS : j’utilise la V11

    NB : Puis je supprimer la ligne CalculateOnLastBars ?

    druby thanked this post
    #197460 quote
    wtangsiri
    Participant
    Junior

    @fifi743
    j’ai mis 100 unités seulement, car, avant la modification, je travaillais en UT 1 Mn et 5 Mn , et les unités m’ont échappé lors de la dernière modification lorsque je rajoute UT 15 Mn

    #197461 quote
    druby
    Participant
    New

    2500 unités c’est 3000 bars bizarre.

    Oui, vous pouvez supprimer “CalculateOnLastBars=10000” Ceci est utilisé pour limiter le nombre de barres utilisées dans les calculs d’indicateurs pour économiser du temps et de la mémoire.

    Voici une version modifiée avec le texte “Anchor -ed” que vous pouvez utiliser directement sur votre panneau de prix si vous le souhaitez. Le texte ne bouge pas lorsque vous redimensionnez votre graphique.

    https://www.prorealcode.com/topic/new-drawing-instructions-anchoring-in-pixels/

    Salutations.

     

     

    DefParam DrawOnLastBarOnly = True
    //DefParam CalculateOnLastBars=10000
    
     
    
    TimeFrame(15 minutes)
    //—-EMA en UT 5 mn—-
    My15MnEMA200 = Average[50,1](close)
    My15MnSMA50 = Average[50,0](close)
    
    TimeFrame(5 minutes)
    //—-EMA en UT 5 mn—-
    My5MnEMA200 = Average[200,1](close)
    My5MnSMA50 = Average[50,0](close)
    
     
    
    TimeFrame(1 minute, Default)
    //—- Calcul du VWAP —-
    d = max(1, intradaybarindex)
    MyVwap = SUMMATION[d](volume*typicalprice)/SUMMATION[d](volume)
    MyVwapRounded = Round(MyVwap, 2)
    
    //—-EMA en UT 1 mn—-
    My1MnEMA200 = Average[200,1](close)
    My1MnSMA50 = Average[50,0](close)
    
    MyPrice = Close
    MyPriceRounded = Round(MyPrice, 2)
    
    //————- Calculations start here ————-
    MyDiffPriceVwap = MyPriceRounded - MyVwapRounded
    
    My15MnAboveEMA200 = Close > My15MnEMA200
    My15MnAboveSMA50 = Close > My15MnSMA50
    
    My5MnAboveEMA200 = Close > My5MnEMA200
    My5MnAboveSMA50 = Close > My5MnSMA50
    
    My1MnAboveEMA200 = Close > My1MnEMA200
    My1MnAboveSMA50 = Close > My1MnSMA50
    
    //============= DEBUT PROGRAMME =============
    
    //—-Current Price Display—-
    DrawText ("Vwap: #MyVwapRounded#",  -240, 125, SansSerif, Bold,     12) anchor(BottomRight) coloured (0,0,0)
    DrawText ("Prix: #MyPrice#",        -140, 125, SansSerif, Standard, 12) anchor(BottomRight) coloured (0,0,0)
    DrawText ("Diff: #MyDiffPriceVwap#", -50, 125, SansSerif, standard, 12) anchor(BottomRight)
    
    DrawText("EMA200                    SMA50 ", -110, 100, dialog, standard,12) anchor(BottomRight)
    
    DrawText("15 Minutes ", -250, 75, dialog, standard,12)anchor(BottomRight)
    DrawText("5 Minutes ",  -250, 50, dialog, standard,12)anchor(BottomRight)
    DrawText("1 Minute ",   -250, 25, dialog, standard,12)anchor(BottomRight)
    
    //—-Affichage Ligne "15 Minutes"—-
    If My15MnAboveEMA200 then
    DrawText("#My15MnEMA200#", -150, 75, dialog, standard,12) anchor(BottomRight) coloured(102,255,0) //Point Vert
    Else
    DrawText("#My15MnEMA200#", -150, 75, dialog, standard,12) anchor(BottomRight) coloured(255,0,0)
    Endif
    If My15MnAboveSMA50 then
    DrawText("#My15MnSMA50#",   -50, 75, dialog, standard,12) anchor(BottomRight) coloured(102,255,0) //Point Vert
    Else
    DrawText("#My15MnSMA50#",   -50, 75, dialog, standard,12) anchor(BottomRight) coloured(255,0,0)
    Endif
    
    //—-Affichage Ligne "5 Minutes"—-
    If My5MnAboveEMA200 then
    DrawText("#My5MnEMA200#", -150, 50, dialog, standard,12) anchor(BottomRight) coloured(102,255,0)
    Else
    DrawText("#My5MnEMA200#", -150, 50, dialog, standard,12) anchor(BottomRight) coloured(255,0,0)
    Endif
    If My5MnAboveSMA50 then
    DrawText("#My5MnSMA50#",   -50, 50, dialog, standard,12) anchor(BottomRight) coloured(102,255,0)
    Else
    DrawText("#My5MnSMA50#",   -50, 50, dialog, standard,12) anchor(BottomRight) coloured(255,0,0)
    Endif
    
    //—-Affichage Ligne "1 Minute"—-
    If My1MnAboveEMA200 then
    DrawText("#My1MnEMA200#", -150, 25, dialog, standard,12) anchor(BottomRight) coloured(102,255,0) //Point Vert
    Else
    DrawText("#My1MnEMA200#", -150, 25, dialog, standard,12) anchor(BottomRight) coloured(255,0,0) //Point Rouge
    Endif
    If My1MnAboveSMA50 then
    DrawText("#My1MnSMA50#",   -50, 25, dialog, standard,12) anchor(BottomRight) coloured(102,255,0) //Point Vert
    Else
    DrawText("#My1MnSMA50#",   -50, 25, dialog, standard,12) anchor(BottomRight) coloured(255,0,0) //Point Rouge
    Endif
    
    //—-Boîtes d'information—-
    DrawRectangle(-290,140,-10,10)  anchor(BottomRight) coloured(220,220,220,100) borderColor(0,0,0,0) // Boîte extérieure
    DrawRectangle(-195,110,-100,10) anchor(BottomRight) coloured(211,211,211,100) borderColor(0,0,0,0) // Boîte intérieure
    //—-Display scales—-
    Return //-3 Coloured(0,0,0,0), 10 Coloured(0,0,0,0)
    wtangsiri and Razz thanked this post
    #197462 quote
    druby
    Participant
    New

    [attachment file=”197463″]

    wtangsiri, Razz, Nicolas and fifi743 thanked this post
    #197466 quote
    wtangsiri
    Participant
    Junior

    Wow

    Bellissimo !!!

    Grazie mólto !!!

    Wow

    belle !!!

    Merci beaucoup !!!

    #197469 quote
    robertogozzi
    Moderator
    Master

    @wtangsiri

    Publiez uniquement dans la langue du forum dans laquelle vous publiez. Par exemple, l’anglais uniquement dans les forums anglophones et le français uniquement dans les forums francophones.

    Merci 🙂

    wtangsiri thanked this post
    #197479 quote
    Razz
    Participant
    Master

    Bonjour Merci de partager cet indicateur ! Dans la ligne 8/9, utilisez la moyenne 50, ne devrait-il pas être 200/50 ? Est-il possible de limiter les décimales de l’affichage des valeurs à 1-2 places, actuellement il y a 5 places ? D’avance merci Pierre

    #197488 quote
    wtangsiri
    Participant
    Junior

    @Razz

    En effet, il y a une petite erreur de frappe sur la ligne 8, c’est EMA 200 et non 50
    Comment partager cet indicateur, moi, personnellement, je veux bien le partager à la communauté

    Pour limiter les décimales de l’affichage à deux, on peut utiliser rounded,2 (comme pour l’affichage du VWAP)

    Razz thanked this post
    #197493 quote
    druby
    Participant
    New

    BJ…

    Bien repéré ‘Razz’, et merci de l’avoir signalé. Oui tu as raison. Doit l’avoir laissé en essayant de déboguer le problème basé sur la description de ‘wtangsiri’. Va juste pour montrer toujours vérifier vous-même pour les erreurs.

    8  My15MnEMA50 = Average[50,1](close)

    8  My15MnEMA200 = Average[200,1](close)

    Concernant le d.p. vous pouvez le faire à plusieurs endroits, au début de la collecte de données ou tard juste avant l’affichage.
    Si ce niveau de précession n’est pas requis, peu importe où vous le faites. Cependant, plus tard, tous les calculs peuvent être effectués avec précision, mais limitez simplement le d.p. à l’affiche. Les résultats peuvent être très différents.

    ROUND(<Numéro>,<dp>)    Numéro – n’importe quel chiffre,  dp –     0-5      0   (default)     ROUND(<Numéro>)

    https://www.prorealcode.com/documentation/round/

    Si vous importez le fichier ci-dessous, vous pouvez comparer le rond, le plafond et le sol à partir de la fenêtre des paramètres de l’indicateur. A mis cela ensemble quand j’apprenais à les connaître. Il y a aussi des conseils pour poser des questions, si vous voyez le côté amusant. Vous devrez traduire les commentaires. copier le code.

    Cordialement.

    a=1.9
    b=3.6
    c = a*b
    
    d=ROUND(a*b)
    drawtext(" a   *   b   =  c",0,100)anchor(middle)
    drawtext("#a#* #b#= #c#",0,80)anchor(middle)
    
    
    x =ROUND(1.9)
    y = ROUND(3.6)
    z = x * y
    
    drawtext(" ROUND(x)  *  ROUND(y)  = z",0,10)anchor(middle)
    drawtext("#x#   *   #y#)  = #z#",0,-10)anchor(middle)
    
    
    //alt 
    
    x =1.9
    y = 3.6
    z = x * y
    
    
    result = ROUND(z)
    drawtext(" (x)  *    (y)  = ROUND(z)",0,-80)anchor(middle)
    drawtext("#x#   *   #y#)  = #result#",0,-100)anchor(middle)
    
    return
    
    
    Razz thanked this post
    #197509 quote
    druby
    Participant
    New

    Voici quelques images qui montrent pourquoi le changement de 200ema a donné n/a à 50ema a donné des valeurs et aussi la différence si mal réglé.

     

    • pic 1 50 ema @ ~ barre 736 (rouge), tandis que 200 ema @ ~ barre 2963 (vert) close (blanc)

     

    • Pic 2 gros plan de la différence si mal réglé.
    timeframe(15minute,updateonclose)
    a = average[50,1](close)
    b = average[200,1](close)
    
    timeframe(default) // 1 minute
    return close, a coloured("red"), b coloured("green")
    
    
    #206806 quote
    rwanderer
    Participant
    New

    Bonjour,

    Le code est sympa. Seulement l’indicateur plante et une erreur s’affiche si l’on est sur UT supérieur à 1 min.
    Y’a t-il une parade à ce problème ?

    #206827 quote
    Nicolas
    Keymaster
    Master

    En effet puisque sans avoir accès à cette unité de temps plus petite, il est impossible de lire le code en entier.

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

Affichage EMA 200 sur UT 1,5 et 15 Mn


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
wtangsiri @wtangsiri Participant
Summary

This topic contains 14 replies,
has 7 voices, and was last updated by Nicolas
3 years, 1 month ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 07/18/2022
Status: Active
Attachments: 5 files
Logo Logo
Loading...