Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding BarSeries

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

    Adding BarSeries

    How to add a BarSeries on a strategy the same with the primary BarSeries? For example, if I set the strategy to run on a Range chart on CL then I would like also the strategy itself a bar series that is a Range. If I set it to run on 2 Minute time frame then the strategy automatically add itself a Minute Bar Series with different period like 5.

    #2
    Hello edward_bell,

    Thanks for your post.

    You can get the bar type with BarsPeriod.Id and the interval with BarsPeriod.Value.

    For example:

    Code:
    Add(Instrument.FullName, BarsPeriod.Id, BarsPeriod.Value+4);
    On a 1 Minute ES 09-13 chart, this would add a secondary series of the ES 09-13 with 5 minute bars.

    BarsPeriod.Id will return the bar type, such as minute or range. BarsPeriod.Value will return the interval (as an integer) to which you can add or subtract from.

    Below is a link to the help guide on BarsPeriod.
    http://www.ninjatrader.com/support/helpGuides/nt7/barsperiod.htm
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello edward_bell,

      Thanks for your post.

      You can get the bar type with BarsPeriod.Id and the interval with BarsPeriod.Value.

      For example:

      Code:
      Add(Instrument.FullName, BarsPeriod.Id, BarsPeriod.Value+4);
      On a 1 Minute ES 09-13 chart, this would add a secondary series of the ES 09-13 with 5 minute bars.

      BarsPeriod.Id will return the bar type, such as minute or range. BarsPeriod.Value will return the interval (as an integer) to which you can add or subtract from.

      Below is a link to the help guide on BarsPeriod.
      http://www.ninjatrader.com/support/helpGuides/nt7/barsperiod.htm
      It cannot be done that way. The notes say that the property BarsPeriod "should NOT be accessed within the Initialize() method."

      Comment


        #4
        koganam,

        You are correct. The help guide does say not to use this in Initialize().

        This code would be an unsupported method as there are some instances that can cause NinjaTrader to crash.

        However, for what edward_bell is trying to accomplish this should work ok. (I did test this first btw)

        Just to re-iterate this is unsupported. The only supported method would be to hard code the secondary series.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          This method works but it makes Ninja to crash or doesn't good to any Dataseries. It will make the indicator so slow. Is there another way?

          Comment


            #6
            Hello edward_bell,

            The only other way would be to hard code the added dataseries and make multiple strategies for each instrument you are wanting to run this strategy over.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Can you please give me example on it?

              Comment


                #8
                Hello edward_bell,

                Below is an example of hard coding an added data series.
                Add("ES 09-13", PeriodType.Minute, 10);

                Also here is a link to the help guide on the Add() function.
                http://www.ninjatrader.com/support/h...s/nt7/add3.htm
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  It is just the same with Add(Instrument.FullName, BarsPeriods[0].Id, 4);. It will will make the indicator too slow or even the chart will freeze.

                  Comment


                    #10
                    Hello,

                    This is the proper supported method of Adding a data series.

                    Is this in the Initialize() part of your script?

                    What is the days to load setting on your chart for the main data series?

                    Is there any other code in your script?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Yes I placed it on the Initialize() section of the code and the primary bar series is based on Days. I have put 3 bar series and the chart will freeze or even adding only 1.

                      Comment


                        #12
                        Is there a way to know if the Bar Type supports multi bar series?

                        Comment


                          #13
                          Hello,

                          What is the days to load setting on your chart for the main data series?

                          What interval is the secondary series? (e.g. 3 Range)
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            I have attached an image on it so that you can see it clearly.

                            I am using 800 Ticks.
                            Attached Files

                            Comment


                              #15
                              Hello edward_bell,

                              This means that you must download 30 days of tick data for this instrument.

                              On my machine this takes approximately 38 seconds. Is this taking much longer for you?

                              Also, I am confused. You mentioned in post #11 that you have a Day interval for the primary data series on the chart.

                              Have you changed this?
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              119 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              62 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              40 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  
                              Started by Mindset, 02-28-2026, 06:16 AM
                              0 responses
                              82 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Working...
                              X