Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Summation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Summation

    Hello,

    If i do a summation summation = SUM(Volume,1235)[0]; it will return the sum of all the volume between 1235 and 0 barsAgo.

    Is it possible to use summation to Sum volume from 1235 to 0 barIndex or from 0 barsAgo to 0 barIndex?

    Ty

    #2
    Hello frankduc,

    Thank you for your post.

    1235 is the number of bars to look back from whatever bar you're referencing, it's not like between specific bars. We'd advise you to use GetValueAt and then create your own method to calculate the sum in this case by looping through the bars you'd want to sum up.



    However, if you wanted the sum of all the bars to the current one, that'd be doable with SUM:

    SUM(Volume, CurrentBar)[0];

    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Kate,

      Than why if i do summation = SUM(Volume, CurrentBar)[0]; the Print(summation); reply Value of property Period of Ninjascript SUM is 0 and not in valid range between 1 and 2147483647?

      This is in OBU.

      thanks

      Comment


        #4
        Hello frankduc,

        Thank you for your reply.

        The SUM() function needs at least 2 bars to sum up. Try putting a CurrentBar check before it:

        if(CurrentBar < 1) return;

        Please let us know if we may be of further assistance to you.

        Comment


          #5
          Kate,

          Is it possible to replace CurrentBar by my variable foundIndex? Cause if i do i still get the message.

          For if(CurrentBar < 1) return; works fine i can get the total number of contracts in the chart.

          Frank

          Comment


            #6
            Hello frankduc,

            Thank you for your reply.

            You could certainly replace CurrentBar with another variable, however, given that I don't know what the variable you asked about holds as far as values, I wouldn't be able to say for sure if the contents of said variable would be a viable replacement.

            Please let us know if we may be of further assistance to you.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            579 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            334 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X