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?


    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()
            {
      [B]         base.OnStateChange();[/B]
               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 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
        22 views
        0 likes
        Last Post Pattontje  
        Started by flybuzz, 04-21-2024, 04:07 PM
        17 responses
        230 views
        0 likes
        Last Post TradingLoss  
        Working...
        X