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 andrewtrades, Today, 04:57 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      6 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      436 views
      0 likes
      Last Post Delerium  
      Started by FAQtrader, Today, 03:35 PM
      0 responses
      7 views
      0 likes
      Last Post FAQtrader  
      Started by rocketman7, Today, 09:41 AM
      5 responses
      19 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X