Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Kate W.NinjaTrader Customer Service

    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.
        Kate W.NinjaTrader Customer Service

        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.
            Kate W.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by cls71, Today, 04:45 AM
            0 responses
            1 view
            0 likes
            Last Post cls71
            by cls71
             
            Started by mjairg, 07-20-2023, 11:57 PM
            3 responses
            213 views
            1 like
            Last Post PaulMohn  
            Started by TheWhiteDragon, 01-21-2019, 12:44 PM
            4 responses
            544 views
            0 likes
            Last Post PaulMohn  
            Started by GLFX005, Today, 03:23 AM
            0 responses
            3 views
            0 likes
            Last Post GLFX005
            by GLFX005
             
            Started by XXtrader, Yesterday, 11:30 PM
            2 responses
            12 views
            0 likes
            Last Post XXtrader  
            Working...
            X