Moyenne des valeurs d’un tableau

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

    Bonjour,

    j’aimerai faire une moyenne d’un tableau (array).

    en théorie, somme de l’ensemble divisé par le nombre de termes, ou somme des x derniers termes divisé par x.

    Je bloque sur la mise en pratique dans PRC, notamment pour récupérer chaque terme et les sommer.

    si vous auriez un exemple je suis preneur.

    Bonne journée.

    #238313 quote
    JS
    Participant
    Senior

    Bonjour,

    Un exemple de calcul d’une moyenne…

    Sum=0
    
    //Fill the array
    For i=0 to 10
    $Array[i]=Close[i]
    Next
    
    //Sum the array values
    For j=0 to LastSet($Array)
    Sum=Sum+$Array[j]
    Next
    
    //Calculate the average
    xAverage=Sum/LastSet($Array)
    
    Return xAverage Coloured("Blue")
    Iván González and P0lyTe55 thanked this post
    #238530 quote
    P0lyTe55
    Participant
    New
    Super, merci pour ton aide !
    #238553 quote
    P0lyTe55
    Participant
    New
    //Fill the array FOR i=0 TO 10 $Array[i] = Close[i] NEXT //Sum the array values Sum = 0 FOR j=0 TO LastSet($Array) Sum = Sum + $Array[j] NEXT //Calculate the average xAverage = Sum / (LastSet($Array)+1) RETURN xAverage Coloured(“lightBlue”)
    Petite correction sur l’avant dernière ligne, on divise par la période, donc 11 en prenant en compte le 0. Le LastSet($Array) renvoyant 10, o lui rajoute un +1
    JS thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Moyenne des valeurs d’un tableau


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
P0lyTe55 @tessaeh Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by P0lyTe55
1 year, 4 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 09/30/2024
Status: Active
Attachments: 1 files
Logo Logo
Loading...