Sommer un tableau $B sous condition $A

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #183202 quote
    PepsmilePepsmile
    Participant
    Veteran

    Afin d’éviter une boucle supplémentaire, serait-il possible de sommer un tableau ($B) en fonction de la valeur d’un autre tableau ($A) ?

    Ici je tente un test où je cherche la somme des valeurs dans le tableau $B (ici 1111 = 202+404+505) sous la condition que $A soit égal à 25.

    « Summation » est-il utilisable ?

    defparam CALCULATEONLASTBARS = 10
     
    $A[1] = 10
    $A[2] = 25
    $A[3] = 30
    $A[4] = 25
     
    $B[1] = 101
    $B[2] = 202 // $A[2] & $A[4] = 25
    $B[3] = 303
    $B[4] = 404 // $A[2] & $A[4] = 25
    $B[5] = 505 // $A[2] & $A[4] = 25
     
    mySom = summation[$B]($A) = 25 // summation[$B]($A = 25) ???
     
    return mySom // résultat attendu = 1111 (202+404+505)
    #183204 quote
    NicolasNicolas
    Keymaster
    Legend

    L’instruction summation n’est pas faite pour cela. Pour faire une somme d’un tableau, il faudra faire une boucle à l’intérieur de celui-ci.

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

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Sommer un tableau $B sous condition $A


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
Pepsmile @pepsmile Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by NicolasNicolas
4 years, 9 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 12/12/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...