Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 usazencortex, Today, 12:43 AM
      0 responses
      1 view
      0 likes
      Last Post usazencortex  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      168 responses
      2,262 views
      0 likes
      Last Post sidlercom80  
      Started by Barry Milan, Yesterday, 10:35 PM
      3 responses
      10 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by WeyldFalcon, 12-10-2020, 06:48 PM
      14 responses
      1,429 views
      0 likes
      Last Post Handclap0241  
      Started by DJ888, 04-16-2024, 06:09 PM
      2 responses
      9 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Working...
      X