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

Access All Existing Data Series on Chart

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

    Access All Existing Data Series on Chart

    I have three data series on a chart.

    They are the following:

    * ES ##-## (Day)
    * NQ ##-## (Day)
    * RTY ##-## (Day)

    The following is true in the indicator OnBarUpdate method:

    Closes.Length == 1
    BarsArray.Length == 1

    I expected all three series would be available much like when one uses AddDataSeries.

    How can an indicator access all of the existing data series that are already on the chart?

    Thanks,

    #2
    OK. I found this which gives access to all the data series in the chart.

    Code:
    for (int i = 0; i < ChartControl.BarsArray.Count; i++)
     {
         var bars = ChartControl.BarsArray[i].
    }
    Can you confirm then that Closes and BarsArray only provide access to the primary chart series in index 0 and then any series added programmatically via AddDataSeries?

    Also, in ChartControl.BarsArray, is the first item in that array always the primary series?

    In the Closes array we can access values using the barsAgo syntax like this

    Code:
    var val1 = Closes[2][barsAgo];
    var val2 = Lows[2][barsAgo];
    var val3 = Opens[2][barsAgo];
    Is there a way to access values in the chart series using barsAgo syntax?

    All I see currently is

    Code:
    var val = ChartControl.BarsArray[2].Bars[barsAgo];
    This returns a double which I assume is the close (?).

    If I wanted the high from a chart series 10 bars ago, how can I do this?

    This would be a nice syntax to have on the Bars object

    Code:
    var val = ChartControl.BarsArray[2].Bars.HIghs[barsAgo];
    Thanks.

    Comment


      #3
      Hello BarzTrading,

      To print the number of series:

      Print(BarsArray.Count);

      Yes, the primary series is always bars Series Index 0.

      To print the high of the primary series from 2 bars ago:

      Print(Highs[0][2]);

      To print the high of the first added series with AddDataSeries() from 2 bars ago:

      Print(Highs[1][2]);

      Yes, price series such as Close, and High are a collection of doubles.


      Below is a public link to the help guide on AddDataSeries().


      A public link on BarsArray.


      A public link on Closes and Highs.



      And a public link on CurrentBars.



      Last, below is a link to a forum post with helpful information about getting started with NinjaScript.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Thanks for your response, Chelsea, however, my question is specifically about multiple data series on the chart, that were not added using AddDataSeries.

        As I mentioned, these appear to be accessible using ChartControl.BarsArray. But only the primary appears in Highs[0], Lows[0]. The other (non primary) chart series do not appear to be accessible this way.

        Comment


          #5
          Hello BarzTrading,

          The data on the chart is Closes[0] or Close when BarsInProgress is 0. This is the primary series. The data on the chart is the primary series.

          To print the high of the primary series from 2 bars ago:

          Print(Highs[0][2]);
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Thanks, but it seems you're not understanding what I'm trying to say.

            I'm talking about ChartControls.BarsArray. These charts. They are the ones that are visible on the chart panel.

            Now, perhaps the disconnect comes from an idea which I have yet to confirm. The idea is that every indicator is associated with one and only one primary series regardless of how many data series are visible on the chart panel. Is this true? If so, then it explains why only the primary is accessible in Highs[0] and Lows[0].

            I am observing that when there are multiple Data Series visible on the chart panel, that only one, the primary, is accessible via Highs[0], Lows[0], etc.

            This probably seems like a simple and obvious concept to you because you're so familiar with it.

            At this point, I'm just looking for confirmation that you understand what I'm talking about and that I'm understanding things correctly. Is this the case?

            Thanks.

            Comment


              #7
              Hello BarzTrading,

              Yes, this is correct. An indicator only uses the series from the chart set as the input series for the script.

              Any other series would need to be added to the script using AddDataSeries().
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Excellent! Thank you.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by jeronymite, 04-12-2024, 04:26 PM
                2 responses
                28 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by Mindset, 05-06-2023, 09:03 PM
                10 responses
                262 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by michi08, 10-05-2018, 09:31 AM
                5 responses
                741 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by The_Sec, Today, 02:29 PM
                0 responses
                2 views
                0 likes
                Last Post The_Sec
                by The_Sec
                 
                Started by tsantospinto, 04-12-2024, 07:04 PM
                4 responses
                62 views
                0 likes
                Last Post aligator  
                Working...
                X