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

How to detect if AddDataSeries works?

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

    How to detect if AddDataSeries works?

    Hi,
    I want to be able to try to load a tick data series using AddDataSeries. If it doesn't work, I want to load an alternative timeframe data series.
    So my question is what reliable tests can be performed to check if the first data series has loaded fully or not as the AddDataSeries return type is void?
    Thanks,
    iq

    #2
    Hello iq200,

    Thanks for your post.

    You may add prints within OnBarUpdate that check if you receive iterations when

    if (BarsInProgress == 1) Print("Added Data Series Iteration");

    which will confirm that you are receiving data for the first added data series in the script. (BarsInProgress == 2 will represent the second data series added to the script.)

    I am also including our Multi Time Frame Instruments documentation which should be referenced when developing Multi Time Frame and Multi Instrument scripts.

    Multi Time Frame and Instruments - https://ninjatrader.com/support/help...nstruments.htm

    Please let us know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Hi Jim,
      Thanks for the reply.
      What I was asking was to be able to check within OnStateChange at the point where I first call AddDataSeries to load the tick data. If the call is successful then I want to continue with the remaining code and NOT call the second AddDataSeries. I want to only call the second AddDataSeries as backup if the first AddDataSeries is unsuccessful. Can I do this?
      Thanks,
      iq

      Comment


        #4
        Hello iq200,

        You can check loaded data series as soon as State.DataLoaded. For example, you could check the following:

        Code:
        foreach (Bars bars in BarsArray)
        {
            Print(String.Format("BarsInProgress: {0} bars.Instrument: {1} bars.BarsPeriod: {2}", BarsInProgress, bars.Instrument.FullName, bars.BarsPeriod.ToString()));
        }
        Data series get added in State.Configure which happens before State.DataLoaded. You could not check data series that are loaded in State.Configure and use that to dynamically add other data series.

        Making sure that you have data to satisfy the AddDataSeries call would involve checking if you have OnBarUpdate iterations of that data series to confirm data is seen for that symbol, or to open a chart of that symbol to confirm data is available for that symbol.
        JimNinjaTrader Customer Service

        Comment


          #5
          OK! Thanks Jim. I wanted to see what the constraints were...

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by sidlercom80, 10-28-2023, 08:49 AM
          172 responses
          2,279 views
          0 likes
          Last Post sidlercom80  
          Started by Irukandji, Yesterday, 02:53 AM
          2 responses
          17 views
          0 likes
          Last Post Irukandji  
          Started by adeelshahzad, Today, 03:54 AM
          0 responses
          4 views
          0 likes
          Last Post adeelshahzad  
          Started by Barry Milan, Yesterday, 10:35 PM
          3 responses
          13 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by WeyldFalcon, 12-10-2020, 06:48 PM
          14 responses
          1,431 views
          0 likes
          Last Post Handclap0241  
          Working...
          X