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

Multiple DataSeries Issue

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

    Multiple DataSeries Issue

    HI, can you tell me why this indicator doesn't process the other dataseries when OnBarUpdate is called? It does when it initially gets loaded.

    Thanks!!
    Attached Files

    #2
    You have five data series => the root plus 4 added series.
    You have no logic to segregate processing of each series. So as a first step in debugging you should
    process each separately.

    Here is a snippet from the help file on how to do that.


    protected override void OnStateChange()
    {
    if (State == State.Configure)
    {
    // Add a 5 minute Bars object: BarsInProgress index = 1
    AddDataSeries(BarsPeriodType.Minute, 5);
    }
    }

    protected override void OnBarUpdate()
    {
    // Check which Bars object is calling the OnBarUpdate() method
    if (BarsInProgress == 0)
    {
    // A value of zero represents the primary Bars which is the ES 09-14
    // 1 minute chart.
    // Do something within the context of the 1 minute Bars here
    }
    else if (BarsInProgress == 1)
    {
    // A value of 1 represents the secondary 5 minute bars added in the Initialize()
    // Do something within the context of the 5 minute Bars
    }
    }

    Comment


      #3
      Thanks for the reply. I don't have any segregated logic because I want it to perform the same steps for each dataseries. If I add this logic it would be just a lot of duplicated code. Is that thought process wrong?

      I tested it and that didn't work. Additionally, this code works fine in a strategy


      Thanks!!
      Last edited by RiversideDude; 04-29-2017, 10:32 AM.

      Comment


        #4
        Hello,

        Thanks for the post.

        Could you provide the output you are getting for the indicator currently?

        Additionally, have you removed the indicator from the chart and re-added it after adding the AddDataSeries syntax? In some cases, the series may not have loaded if the instance was not replaced.

        Finally, are you able to pull up the secondary instruments with the settings you had used in the script in a chart to see the data?

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Attached is the output that I get when the indicator is initially enabled and after I start the market playback.I did remove and re-add the indicator. Not sure I understand your last question.

          Thanks!!
          Attached Files
          Last edited by RiversideDude; 04-29-2017, 10:02 PM.

          Comment


            #6
            Good news, it works when the market is "Live". I was testing it during playback, I bet I didn't have the data for the other dataseries downloaded.

            Thanks for the help!!

            Comment


              #7
              I'm trying to add a variable to count the number of dataseries processed but I can't figure out were to initialize it.

              For example: This indicator has 7 dataseries. I want to know once the 7th dataseries has been processed.

              Thanks!!
              Attached Files

              Comment


                #8
                State==State.DataLoaded

                Comment


                  #9
                  Hello,

                  You could use State.DataLoaded for any logic that needs to occur once data has loaded. You can see when each state is triggered in the following document:


                  I look forward to being of further assistance.
                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    Thanks JerryWar and Jesse.

                    Comment


                      #11
                      It didn't work quite as expected since DataLoaded is called only once after all data series have been loaded. What about every time a new bar closes?

                      Comment


                        #12
                        can someone let me know if this is possible?

                        Thank!!

                        Comment


                          #13
                          OnbarUpdate()

                          Comment


                            #14
                            I did. I also tried State==State.DataLoaded in OnBarUpdate and no luck, it doesn't trigger. It only triggers for the initial load, but not for any bar closes that happens after that.

                            Thanks!!

                            Comment


                              #15
                              State.DataLoaded occurs in OnStateChange()

                              Bar Updates occur in OnBarUpdate()

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by jclose, Today, 09:37 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post jclose
                              by jclose
                               
                              Started by WeyldFalcon, 08-07-2020, 06:13 AM
                              10 responses
                              1,413 views
                              0 likes
                              Last Post Traderontheroad  
                              Started by firefoxforum12, Today, 08:53 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post firefoxforum12  
                              Started by stafe, Today, 08:34 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post stafe
                              by stafe
                               
                              Started by sastrades, 01-31-2024, 10:19 PM
                              11 responses
                              169 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Working...
                              X