Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Avoid Duplicate Data Series in Strategy

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

    Avoid Duplicate Data Series in Strategy

    In a multi-Instrument Strategy, how does one avoid adding the selected primary Data Series as an additional Data Series, thereby duplicating it?

    My approach has been to check Instruments[0].FullName in State.Configure ... but from what I read in the Help docs, the Instruments array should not be accessed before State.DataLoaded.

    Thanks.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    #2
    Originally posted by jeronymite View Post
    In a multi-Instrument Strategy, how does one avoid adding the selected primary Data Series as an additional Data Series, thereby duplicating it?
    Are you finding issues around this duplication that you're
    trying to mitigate?

    Are you just trying to 'be nice' to AddDataSeries?

    Comment


      #3
      The latter. As a matter of principle, avoid the extra (redundant) Data Series, particularly if one has many to load. It also adds an extra index into the melee when cycling through various things.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        Hello jeronymite,

        Thanks for your question.

        This would fall into the realm of dynamically adding data series (loading data based on the data already loaded or based on user input.) This is not fully supported and does not work specifically with optimizations, but you may find it does work in many if not most situations. Checking the primary data series in State.Configure may work well enough for you, and if it fits your needs, you are welcome to use it there.

        For the thread's reference, the AddDataSeries documentation which lists the tips and warnings for using the method can be found here - https://ninjatrader.com/support/help...dataseries.htm

        If the code needs to work in all cases, you could consider reviewing each data series in State.DataLoaded, and you can then control which BarsInProgress indexes get used in your strategy code.

        We look forward to assisting.

        Comment


          #5
          Originally posted by jeronymite View Post
          In a multi-Instrument Strategy, how does one avoid adding the selected primary Data Series as an additional Data Series, thereby duplicating it?

          My approach has been to check Instruments[0].FullName in State.Configure ...
          Hi jeronymite,

          Just an FYI.. I face a similar challenge. The following code seems to work well enough. I have noticed that, as Jim hints at, testing the Primary data series in State.Configure more reliable than following series.

          Code:
          
          {
          else if (State == State.Configure)
          {
          ...
          
          string barPeriodTypeName = ChartBars.Properties.BarsPeriod.BarsPeriodType.ToS tring();
          
          if(barPeriodTypeName != myTargetedCustomBarType)
                 AddDataSeries( Load my targeted custom bar type );
          
          }

          Jim, if there as better preferred best practice to solve this problem please do tell. I am all ears.

          Thanks,
          HedgePlay

          Comment


            #6
            Thanks, bltdavid , NinjaTrader_Jim and hedgeplay .

            I run Strategies from Control Center. It seems that using Instruments[0].FullName in State.Configure will be "safe enough". Additional checks/decisions in State.DataLoaded, as mentioned by Jim, are useful too.

            Thanks.
            Multi-Dimensional Managed Trading
            jeronymite
            NinjaTrader Ecosystem Vendor - Mizpah Software

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            64 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            139 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            75 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            45 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            50 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X