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

Count the number of Add(), plots.

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

    Count the number of Add(), plots.

    How can I count the number of Add()? I'd like to know how many stock "data series" are in existence.
    Also how do you count the number of plots?

    #2
    Hello clocker,
    If you use the below code then can you get the plot counts.

    Code:
    int plotCount = Plots.Length;
    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Thanks, but more important how about counting added stock dataseries like Add("NITE", PeriodType.Day, 1);?

      Comment


        #4
        Hello clocker,
        You can check that with the BarsArray property

        Code:
        BarsArray.Length
        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          I used BarArray.Length but I got 1 more listed than I've added (I commented out all plots too) which is the extra array is it counting and is it possible to get the type (plot or stock) or the name of array stored?

          Comment


            #6
            Hello clocker,
            Plots, BarsArray are arrays. They are zero based.

            BarsArray[0] -- refers to the primary bar series
            ...

            BarsArray[BarsArray.Length - 1] -- refers to the last secondary series.


            Can you tell me the code snippet you are using.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              I run this in Initialize()
              Code:
              Overlay= false;
              Add("AKSO.OL", PeriodType.Day, 1);
              Add("ALGETA.OL", PeriodType.Day, 1);
              then I run in OnBarUpdate()
              Code:
              print(BarArray.Length);

              Comment


                #8
                Hello clocker,
                You will get 3 as the result.

                The first bar is the primary bar series (on which you have applied the NinjaScript code). The first secondary bar series will be that of AKSO.OL and the second secondary series will be that of ALGETA.OL
                JoydeepNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by WHICKED, Today, 12:45 PM
                2 responses
                16 views
                0 likes
                Last Post WHICKED
                by WHICKED
                 
                Started by GussJ, 03-04-2020, 03:11 PM
                15 responses
                3,272 views
                0 likes
                Last Post xiinteractive  
                Started by Tim-c, Today, 02:10 PM
                1 response
                8 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by Taddypole, Today, 02:47 PM
                0 responses
                2 views
                0 likes
                Last Post Taddypole  
                Started by chbruno, 04-24-2024, 04:10 PM
                4 responses
                51 views
                0 likes
                Last Post chbruno
                by chbruno
                 
                Working...
                X