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

Indicator on Multiple Instruments

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

    Indicator on Multiple Instruments

    HI,

    Suppose I create a chart with multiple instruments. Furthermore, suppose I create this chart through Data Series rather than programatically via Add(). If I have a custom indicator that say simply plots 2*Close[0], I can use this indicator on each of the instruments on the chart.

    Here is the issue: How does the indicator know which instrument data series to use? I realize that part of the information comes from the input series. So if I specify the Input series as the correct instrument but say I specify it as the Low of that instrument, my indicator will still work correctly even though it is simply referencing the Close. I am assuming here that in this instance the Close is simply being replaced by some version of Bars.GetClose(lastBar).

    I realize this is likely unsupported but can anyone please shed some light on how NT determines from the input series specified which series close the Close[0] refers to? I would be very appreciative. Thank you.

    #2
    Hello Zeos6,
    You can use the below unsupported code to get the bar series as applied on the chart
    Code:
    ChartControl.BarsArray[0]
    ChartControl.BarsArray[1]
    The ChartControl class is not officially supported and thus not documented.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Thank you for your reply, but you are not answering the question. I know I can use ChartControl.BarsArray[index]. The issue is that when I use Close[0] how does it get the index from the Input series?

      Comment


        #4
        Hello Zeos6,
        Close[0] will specifically refer to the primary bar only.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          I believe I have found the answer. The index comes from BarsInProgress of the Input Series. Can you please confirm this? Thanks.

          Comment


            #6
            Hello Zeos6,
            BarsInProgress will referenced only if you add the secondary bar series via the Add() method.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              Then how does it get the index reference? The fact is that it works. So please explain. Thanks.

              Comment


                #8
                Hello Zeos6,
                If you simply try the below code then are you able to determine the bar

                Code:
                foreach (Bars bar in ChartControl.BarsArray)
                {
                	if (bar == Bars)
                	{
                		//do something
                	}
                }
                JoydeepNinjaTrader Customer Service

                Comment


                  #9
                  This does work, thank you very much. Not sure, however, how to use this to extract the index for use with BarsArray[index].

                  Comment


                    #10
                    Hello Zeos6,
                    The BarsInProgess property is not available in the Bars class. It is available in the Indicators and strategies class only.

                    The best you can do is to find the panel information using the below unsupported code.

                    Code:
                    ChartControl.BarsArray[0].BarsData.Panel
                    JoydeepNinjaTrader Customer Service

                    Comment


                      #11
                      Hi Joydeep,

                      This simply returns an integer - 0 in my case. What specific information is provided by

                      ChartControl.BarsArray[0].BarsData.Panel

                      Also, what specific information is returned by

                      ChartControl.BarsArray[0].BarsData.PanelUI

                      Thanks.

                      Comment


                        #12
                        Hello Zeos6,
                        ChartControl.BarsArray[0].BarsData.Panel will simply return the panel number infor.

                        For example if you set the chart as the attached screenshot then it (ChartControl.BarsArray[0].BarsData.Panel) will return 1.

                        Unfortunately thee ChartControl Class is not officially supported by us and thus its properties are not documented.
                        Attached Files
                        JoydeepNinjaTrader Customer Service

                        Comment


                          #13
                          Thank you Joydeep. I realize that ChartControl is unsupported and I am thank ful that you are willing to answer a few questions about it. Can you please let me know what information the

                          ChartControl.BarsArray[0].BarsData.PanelUI

                          provides? Thank you very much.

                          Comment


                            #14
                            Hello Zeos6,
                            PanelUI is the panel number where the Data Series will be plotted. Seems it is the exposed member (and non zero based).
                            JoydeepNinjaTrader Customer Service

                            Comment


                              #15
                              Thank you very much.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Christopher_R, Today, 12:29 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post Christopher_R  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              166 responses
                              2,235 views
                              0 likes
                              Last Post sidlercom80  
                              Started by thread, Yesterday, 11:58 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post thread
                              by thread
                               
                              Started by jclose, Yesterday, 09:37 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post jclose
                              by jclose
                               
                              Started by WeyldFalcon, 08-07-2020, 06:13 AM
                              10 responses
                              1,415 views
                              0 likes
                              Last Post Traderontheroad  
                              Working...
                              X