Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ChartBars & ChartControl "Primary Series"

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

    ChartBars & ChartControl "Primary Series"

    How do you define "Primary Series" in charts? Is it the data fed into the script / indicator? or is it the first one got imported into the "Data Series" Tab?

    I do realized different objects ( ChartBars / ChartControl) might defined them differently, but how specifically?
    Code:
    // They don't always print out the same thing
    Print(ChartControl.BarsArray[0].Properties.Instrument);
    Print(ChartBars.Properties.Instrument);​
    ************************************************** *****************************
    More Context :

    I am confused because the documentation uses them interchangeably, for example, under ChartControl​ there is:
    BarsPeriod​ : Provides the period (interval) used for the primary Bars object on the chart​​
    And also under ChartBars ​there is:
    The ChartBars class provides GUI access related methods and properties to the primary bars series configured on the Chart through the Data Series menu.​
    Last edited by Curerious; 03-28-2025, 02:06 PM.

    #2
    Hello Curerious,

    The primary series is always the series which you applied the script to. If you have other series loaded in the chart those are not used at all.​

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello Curerious,

      The primary series is always the series which you applied the script to. If you have other series loaded in the chart those are not used at all.​
      Hi Jesse,

      But if I use the following code, it printed out the first series's BarsPeriod that I manually imported into the "Data Series" Tab, instead of the series I applied the script to... Thats why I am confusing, what exactly is the term "Primary Bars​"​ referring to, does it have different meanings under different contexts?
      Code:
      Print(ChartControl.BarsPeriod);
      ************************************************** **
      BarsPeriod​ : Provides the period (interval) used for the primary Bars object on the chart​
      It says "Primary Bars​", isn't that suppose to be the series I applied the script to ?
      Last edited by Curerious; 03-28-2025, 02:06 PM.

      Comment


        #4
        Hello Curerious,

        You can see what series you applied the script to by opening the indicators properties dialog and look at Input series.

        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Hello Curerious,

          You can see what series you applied the script to by opening the indicators properties dialog and look at Input series.
          Yes, I have 3 series loaded into chart by using the "Data Series" Tab​, which follows the order of:
          1. ES (1 Minute)
          2. YM (5 Minute)
          3. NQ (15 Minute)

          Then I applied Input series "YM (5 Minute)" into the indicator, and my indicator have following logic only:
          Code:
          protected override void OnStateChange()
          {
                  ...
                  if (State == State.Historical)
                  {
                       Print(ChartControl.BarsPeriod);
                  }
          }​
          Then it prints out "1 Minute". Isn't it suppose to be "5 Minute" as you claimed? Since my input series is "YM (5 Minute)" ?

          Comment


            #6
            Hello Curerious,

            Yes those properties go with the primary series. You might have a different setup which is causing that. The following script always prints the primary series timeframe for me. If you are seeing something else collect the steps you used with this sample and post again.



            Code:
                public class TestBarsPeriod: Indicator
                {
                    protected override void OnStateChange()
                    {
                        if (State == State.SetDefaults)
                        {
                            Description                                    = @"Enter the description for your new custom Indicator here.";
                            Name                                        = "TestBarsPeriod";
                            Calculate                                    = Calculate.OnEachTick;
                            IsOverlay                                    = false;
                            DisplayInDataBox                            = true;
                            DrawOnPricePanel                            = true;
                            DrawHorizontalGridLines                        = true;
                            DrawVerticalGridLines                        = true;
                            PaintPriceMarkers                            = true;
                            ScaleJustification                            = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                            //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                            //See Help Guide for additional information.
                            IsSuspendedWhileInactive                    = true;
                        }    
                            if (State == State.Historical)
                            {
                                 Print(ChartControl.BarsPeriod);
                            }
                    }
            
            
                    protected override void OnBarUpdate()
                    {
            
                    }
                }
            }​

            Comment


              #7
              Originally posted by NinjaTrader_Jesse View Post
              Hello Curerious,

              Yes those properties go with the primary series. You might have a different setup which is causing that. The following script always prints the primary series timeframe for me. If you are seeing something else collect the steps you used with this sample and post again.



              Code:
              public class TestBarsPeriod: Indicator
              {
              protected override void OnStateChange()
              {
              if (State == State.SetDefaults)
              {
              Description = @"Enter the description for your new custom Indicator here.";
              Name = "TestBarsPeriod";
              Calculate = Calculate.OnEachTick;
              IsOverlay = false;
              DisplayInDataBox = true;
              DrawOnPricePanel = true;
              DrawHorizontalGridLines = true;
              DrawVerticalGridLines = true;
              PaintPriceMarkers = true;
              ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
              //Disable this property if your indicator requires custom values that cumulate with each new market data event.
              //See Help Guide for additional information.
              IsSuspendedWhileInactive = true;
              }
              if (State == State.Historical)
              {
              Print(ChartControl.BarsPeriod);
              }
              }
              
              
              protected override void OnBarUpdate()
              {
              
              }
              }
              }​
              Just to make sure you followed the same step as mine, Did you inserted the series using "Data Series" Tab as I did with the exact order ? (see attached pictures) And Did you applied Input series "YM (5 Minute)" into the indicator as I did?
              Attached Files
              Last edited by Curerious; 03-28-2025, 03:28 PM.

              Comment


                #8
                Hello Curerious,

                Yes that is correct, you are referencing the ChartControl variable which is the main series on the chart.

                If you are trying to access the series information where you applied the script to you have to reference the scripts primary series and not the ChartControl.

                Print(BarsArray[0].BarsPeriod.Value);

                Comment


                  #9
                  Originally posted by NinjaTrader_Jesse View Post
                  Hello Curerious,

                  Yes that is correct, you are referencing the ChartControl variable which is the main series on the chart.

                  If you are trying to access the series information where you applied the script to you have to reference the scripts primary series and not the ChartControl.

                  Print(BarsArray[0].BarsPeriod.Value);
                  True, thank you for understanding and replying.

                  My point being : the NT document made the term "Primary Series" unclear, they didn't have an explicit definition for it and used it interchangeably. A note in the corresponding document would be much appreciated by the developers.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by argusthome, 03-08-2026, 10:06 AM
                  0 responses
                  65 views
                  0 likes
                  Last Post argusthome  
                  Started by NabilKhattabi, 03-06-2026, 11:18 AM
                  0 responses
                  41 views
                  0 likes
                  Last Post NabilKhattabi  
                  Started by Deep42, 03-06-2026, 12:28 AM
                  0 responses
                  23 views
                  0 likes
                  Last Post Deep42
                  by Deep42
                   
                  Started by TheRealMorford, 03-05-2026, 06:15 PM
                  0 responses
                  26 views
                  0 likes
                  Last Post TheRealMorford  
                  Started by Mindset, 02-28-2026, 06:16 AM
                  0 responses
                  52 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Working...
                  X