Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding new bars object dynamically..

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

    Adding new bars object dynamically..

    Hi ninjas,

    I´d like to know how to add a variable numbers of new bars object if I need them in order to do certain statisticals, instead just to add them just a fix numbers at first of the code. I mean: let´s say that for certain month I´d like to evaluate 3 different bars object but for the next month I´d need 4 one.

    The normal way is setting them is like this:

    protected override void Initialize()
    {
    Add("$EURUSD", PeriodType.Tick, x); // adding #1
    Add("$EURUSD", PeriodType.Tick, x); // adding #2

    But I´d like to be able to add them dynamically for optimization, 2, 3...etc etc

    If not, is there any procedure or function in a library that I can use it?

    Thanks

    #2
    Hello pstrusi,
    Unfortunately you cannot use the Add() method to add additional bar series dynamically. The Add() method will add the additional bar series only when you initialize the strategy.

    Depending on what you are using you can use the below unsupported code to load a bar series on the fly.
    NinjaTrader.Data.Bars.GetBars(...)

    Please refer to this post which further discusses on it.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Why not in a "for loop"

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      574 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      333 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X