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

Bars Type Property

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

    Bars Type Property

    Hi, is it possible to get a bars type property in my ninjascript, like this?

    Click image for larger version

Name:	image.png
Views:	110
Size:	1.7 KB
ID:	1227193

    #2
    Hello shildebrand324,

    Thanks for your post.

    You could get the BarsPeriodType that a script is enabled on by using Bars.BarsPeriod.BarsPeriodType.

    For example, if we add a print in a scrip that looks like, Print(Bars.BarsPeriod.BarsPeriodType); and we enable the script on a 1-Minute ES 03-23 chart, the print output will read 'Minute'.

    See this help guide page for more information about BarsPeriod: https://ninjatrader.com/support/help...barsperiod.htm

    Let me know if I may further assist you.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      But I'm wanting a drop down in my script that shows the bar types, so I can pick it for my indicator.

      Comment


        #4
        Hello shildebrand324,

        Thanks for your note.

        Are you referring to dynamically adding additional data series to an indicator script so that the BarsType of the added series can be set by a user-defined property?

        If so, dynamically adding additional data series is not supported. The BarsType value would need to be hardcoded into the AddDataSeries() method(s) in the indicator script.

        From the AddDataSeries() help guide page linked below:

        Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided.

        AddDataSeries(): https://ninjatrader.com/support/help...dataseries.htm

        Please let me know if I may further assist.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          So, I'd have to have a different version of the indicator for each bar type?

          Comment


            #6
            Hello shildebrand324,

            Thanks for your note.

            I am not entirely sure I understand what you mean.

            Please provide a brief description that explains exactly what your goal is so that I may accurately assist.

            For example, are you creating an indicator and you want to add that indicator to an instrument on a chart that has a certain BarType?

            If so, you would need to add the indicator to each data series bar type you want to run the indicator on. You could consider adding multiple data series to a single chart window that uses different BarTypes and apply to indicator to each data series added to that chart window.

            See the help guide pages below for more information.
            Working with Multiple Data Series on a Chart: https://ninjatrader.com/support/help...ata_series.htm
            Working with Indicators on a Chart: https://ninjatrader.com/support/help...indicators.htm

            Thanks in advance; I look forward to assisting further.
            Last edited by NinjaTrader_BrandonH; 12-12-2022, 03:07 PM.
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              I need to have the bar data series bar type based on a property value, instead of hardcoded, or the secondary data series bar type, have the same as primary
              Last edited by shildebrand324; 12-12-2022, 03:15 PM.

              Comment


                #8
                Hello shildebrand324,

                Thanks for your note.

                I understand that you have an indicator script that uses AddDataSeries() to add secondary data series to the script.

                The instrument, bar type, and value of the added series must be hardcoded as stated in the AddDataSeries() help guide page linked in post # 4. We would not be able to assist with dynamically adding secondary series since it is not supported.

                This thread will be open for other community members to share their insights on unsupported code to accomplish this.

                Let me know if I may assist further.
                Brandon H.NinjaTrader Customer Service

                Comment


                  #9
                  I'm actually doing the below, and would like for the BarsPeriodType.Range to come from the primary data series type.

                  AddVolumetric(null, BarsPeriodType.Range,BarsPeriod.Value,VolumetricDe ltaType.BidAsk,1);

                  Comment


                    #10
                    Hello shildebrand324,

                    Thanks for the clarification.

                    The instrument name could be set to null or set to an empty string, such as " " to set the instrument to the primary series. However, all the other values such as BarsPeriodType, BarsPeriodTypeValue, etc. must be hardcoded in the AddVolumetric() method.

                    Please let me know if you have further questions.
                    Brandon H.NinjaTrader Customer Service

                    Comment


                      #11
                      BarsPeriod.Value pulls from the primary series, didn't see a .Value for BarsPeriodType

                      Comment


                        #12
                        Hello shildebrand324,

                        Thanks for your note.

                        We do not have any supported means for setting the BarsPeriodType argument of the AddVolumetric() method to use the primary series BarsType. This value would need to be hardcoded as stated in my previous post.

                        This thread will be open for community members to share their insights on unsupported code.

                        Let me know if you have further questions.
                        Brandon H.NinjaTrader Customer Service

                        Comment


                          #13
                          But is there a way for me to make a custom property that has the bar type enumeration?

                          Comment


                            #14
                            Hello shildebrand324,

                            Thanks for your note.

                            No, there are no supported or documented ways for accomplishing this. As previously stated, the value would need to be hardcoded in your additional data series method, such as AddVolumetric().

                            That said, this thread will be open for other community members to share their insights.

                            Let me know if I may assist further.
                            Brandon H.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by JesseOffshore, Today, 09:40 PM
                            0 responses
                            1 view
                            0 likes
                            Last Post JesseOffshore  
                            Started by WHICKED, 04-26-2024, 12:56 PM
                            4 responses
                            139 views
                            0 likes
                            Last Post WHICKED
                            by WHICKED
                             
                            Started by ezrollin, 02-26-2022, 11:14 PM
                            7 responses
                            207 views
                            0 likes
                            Last Post kenz987
                            by kenz987
                             
                            Started by rocketman7, Today, 08:34 PM
                            0 responses
                            5 views
                            0 likes
                            Last Post rocketman7  
                            Started by rt61968, 02-17-2018, 05:24 PM
                            3 responses
                            2,736 views
                            0 likes
                            Last Post MasterEtrad3  
                            Working...
                            X