• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Feature Request - DataSeries Identifiers

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

    Feature Request - DataSeries Identifiers

    In NT8 is there a way to lookup the Id of the data series we add in multi-series indicators/strategies?

    Without it we have to track it ourselves with code like this:

    Code:
                int m_seriesDay;
                int m_dataSeriesCounter = 0;
                ... 
                AddDataSeries(PeriodType.Minute, 1440);
                m_seriesDay = ++m_dataSeriesCounter;
                // get Daily close:
                double close = Closes[m_seriesDay][0];
    That's fine for a small indicator or strategy but when we start combining components that add their own series it gets difficult. We're force to write some "data series dispenser" object that centralizes and tracks the ids so that the correct Ids are used by a larger program.

    Can the AddDataSeries API be changed to return the Id?
    Code:
    m_seriesDay = AddDataSeries(PeriodType.Minute, 1440);
    I had asked for this years ago and I know there's a feature request for it. Was it ever considered for NT8?

    #2
    Hello,

    Are you referring to the BarsInProgress index?
    http://ninjatrader.com/support/helpG...barsinprogress

    This exists in both NT7 and NT8 and would represent the Index of the dataseries currently calling OnBarUpdate. The indexes are created top to bottom meaning the index 0 is always the primary, next added series is always index 1, second added is always index 2 etc.


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

    Comment


      #3
      No, BarsInProgress is a little bit different ( although related )..
      BIP represents id of the bars for the current call to OnBarUpdate.

      In any call to OnBarUpdate ( or any other event ) one can reference ANY bar series... not just the one that's in progress.

      Building on the example in the previous post
      Code:
      if( BarsInProgress == 0 )
      {
      // still okay to reference another bars in progress
      // m_seriesDay == 1, the 1440 minute bar series IDENTIFIER
      // Get the ADX of the daily bars. Do this while BIP is == 0, just for illustation. 
      // Could be done on any BIP value. Also assume primary series is something other
      // than 1440 minute bars, just to illustrate that it's a different series
            ADX adx = ( Closes[ m_seriesDay ], 14 );
      }
      All throughout our NinjaScript we will have references to the BarsArray property, passing in the id of the bars we want to query.

      In the example I provided we can rely on the series for the daily bars to be 1 BECAUSE we know that we called AddDataSeries only once.

      BUT, if we derive our code from another indicator or strategy, and call the base classes OnConfigure from our own:

      Code:
            protected override void OnStateChange()
            {
               base.OnStateChange();
               if (State == State.SetDefaults)
               {
                  Description = @"Volume Vector2 adds daily filter";
                  Name = "AtsVolumeVector2";
               }
               else if (State == State.Configure)
               {
                  AddDataSeries(PeriodType.Minute, 1440);
                  seriesDay = ++m_dataSeriesCounter;
               }
            }
      How do we know whether or not base.OnStateChange added it's own DataSeries ???
      If it does then we can't depend on 1 being the id of the 1440 minute bars that we add in our derived class.

      This problem would easily by solved if AddDataSeries simply returned the Id.

      This is what I asked for years ago and it would greatly simplify writing larger and BETTER Ninjascripts.

      Comment


        #4
        Hello,

        Thank you for the additional details, I will put in a feature request for the method to return an index.

        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by siroya, Today, 06:32 AM
        0 responses
        3 views
        0 likes
        Last Post siroya
        by siroya
         
        Started by fluffier, Yesterday, 11:49 PM
        1 response
        20 views
        0 likes
        Last Post NinjaTrader_Marco  
        Started by GARZONJ, Yesterday, 09:02 PM
        0 responses
        11 views
        0 likes
        Last Post GARZONJ
        by GARZONJ
         
        Started by bouncetherubble, Yesterday, 08:42 PM
        0 responses
        8 views
        0 likes
        Last Post bouncetherubble  
        Started by connorgrant5, Yesterday, 01:33 PM
        1 response
        18 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Working...
        X