Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

"Dynamic" Rollover

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

    "Dynamic" Rollover

    Hi,
    I have to add on State.Cnfigure new dataseries
    else if (State == State.Configure)
    {
    AddDataSeries(sInstrument1,BarsPeriodType.Minute, 1); // this is bar series xxx ....

    And I previously define
    private string sInstrument1 = "ES 03-23";

    I can find a lot of information using
    private SessionIterator sessionIterator; well, After i define my dataseries.

    Question is that possible to figure out that i need to switch to "ES 06-23" "dynamically" as this action has to be done before State.Configure obviously using code?

    -PNF.


    #2
    Hello PNF,

    Thank you for your post.

    The following note from the AddDataSeries() page in the help guide is relevant here:
    "Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner.​"

    With that said, you could try the suggestion in the following forum post where you write a method that fetches the current expiry in the NinjaTrader database based on the symbol name:
    I'm creating a strategy that will include a AddDataSeries of MES 1-minute. Strategy builder has taken care of the details of that. I'm wondering what happens at expiry? When we roll over to a new contract symbol, since the strategy must be compiled before running, will the code need to be edited and recompiled manually?


    Otherwise, you would need to manually adjust your AddDataSeries() logic when you are ready to roll over, then compile and re-load the strategy to pick up the changes.

    Please let us know if we may be of further assistance.

    Comment


      #3
      Well, i have read this note to AddDataSeries that was one of the reason to ask question to begin with, and yes, i'm using something similar to the post indicated. As note is type of "limitation" (without discussion is or is not) i would have to end-up with data series that i do not need to run strategy, they will be "there", consuming resources and memory, as i additionally would like to know Volume, and there is no way to get this w/o having bars loaded. Because of this i have a question what is the reasonable limit of have many data series i can load, outside of the obvious answer - depending on your hardware.
      -PNF

      Comment


        #4
        Hello PNF,

        Thank you for your reply.

        There is no "reasonable limit" that I would be able to quote; it is not a magic number and it truly depends on your PC resources as well as the calculations and demand from the script itself. You would have to keep the NinjaScript Best Practices in mind as well as Performance Tips which can both be found in the help guide:Please let us know if we may be of further assistance.

        Comment


          #5
          Thank you.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          23 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          120 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          63 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          45 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X