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 Skifree, Today, 03:41 AM
                1 response
                2 views
                0 likes
                Last Post Skifree
                by Skifree
                 
                Started by usazencort, Today, 01:16 AM
                0 responses
                1 view
                0 likes
                Last Post usazencort  
                Started by kaywai, 09-01-2023, 08:44 PM
                5 responses
                603 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by xiinteractive, 04-09-2024, 08:08 AM
                6 responses
                23 views
                0 likes
                Last Post xiinteractive  
                Started by Pattontje, Yesterday, 02:10 PM
                2 responses
                23 views
                0 likes
                Last Post Pattontje  
                Working...
                X