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

Calling custom BarTypes inside Indicator

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

    Calling custom BarTypes inside Indicator

    Hello there,

    I recently moved from NT7 to NT8 and had a custom BarType created for me.

    It is called (BarsPeriodType) 584

    When I call

    if (BarsPeriod.BaseBarsPeriodType == (BarsPeriodType) 584)

    nothing happens.

    Do I need to use the AddDataSeries() function beforehand? What would be the period and where do I put it?

    Thank you.

    #2
    Hello ij001,

    You may want to try:

    if ((int)BarsPeriod.BaseBarsPeriodType == 584)


    If you are wanting to add the bar type as a secondary series to the script, yes, AddDataSeries() would be used.

    The help guide has a note about this:
    "2. You can add a custom BarsType which is installed on your system by casting the registered enum value for that BarsPeriodType. For example: AddDataSeries((BarsPeriodType)14, 10);

    3. You can specify optional BarsPeriod values (such as Value2) of a custom BarsType in the BarsPeriod object initializer. For example: AddDataSeries(new BarsPeriod() { BarsPeriodType = (BarsPeriodType)14, Value = 10, Value2 = 20 });"



    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello ij001,

      You may want to try:

      if ((int)BarsPeriod.BaseBarsPeriodType == 584)


      If you are wanting to add the bar type as a secondary series to the script, yes, AddDataSeries() would be used.

      The help guide has a note about this:
      "2. You can add a custom BarsType which is installed on your system by casting the registered enum value for that BarsPeriodType. For example: AddDataSeries((BarsPeriodType)14, 10);

      3. You can specify optional BarsPeriod values (such as Value2) of a custom BarsType in the BarsPeriod object initializer. For example: AddDataSeries(new BarsPeriod() { BarsPeriodType = (BarsPeriodType)14, Value = 10, Value2 = 20 });"
      https://ninjatrader.com/support/help...dataseries.htm

      Thank you for your quick reply.

      I tried

      if ((int)BarsPeriod.BaseBarsPeriodType == 584)

      but still nothing.

      I do not believe I need to add this dataseries. What I am trying to achieve is when I toggle between charts the indicator identifies which chart I am on and runs the appropriate code.

      For example, a range chart then I toggle to this custom bar chart.

      Any further thoughts?

      Comment


        #4
        Hello ij001,

        If you print:

        Print((int)BarsPeriod.BaseBarsPeriodType);

        What prints to the output window?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello ij001,

          If you print:

          Print((int)BarsPeriod.BaseBarsPeriodType);

          What prints to the output window?
          4

          So I updated if ((int)BarsPeriod.BaseBarsPeriodType == 4)

          and it works now.

          Thank you!

          Comment


            #6
            Hello ij001,

            This would indicate that the primary series is not your custom bar type.

            A value of 4 would be a Minute chart.

            Are you certain your custom bar type is selected on the chart?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              Hello ij001,

              This would indicate that the primary series is not your custom bar type.

              A value of 4 would be a Minute chart.

              Are you certain your custom bar type is selected on the chart?
              The custom bartype is a mirror of the Range Bar. So visually it has always shown up a mirror image.

              Now when I call the indicator with a value of 4, it plots on the Mirror Range Bar.

              I can email you the bartype if you are able to confirm?

              Comment


                #8
                Hello ij001,

                BarsPeriodType Ids 1-12 are reserved by NinjaTrader for the bar types included with NinjaTrader.

                You can use the BarsType Identifier to print out the names of the BarsTypes.
                This is just a simple script which prints the BarsTypes and their BarsPeriodType ID as an integer. This is to aid in finding BarsPeriodType ID’s for the use with AddDataSeries syntax. For more apps from this user, check out the Trendline Detection tool!



                The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by usazencort, Today, 01:16 AM
                0 responses
                1 view
                0 likes
                Last Post usazencort  
                Started by kaywai, 09-01-2023, 08:44 PM
                5 responses
                603 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by xiinteractive, 04-09-2024, 08:08 AM
                6 responses
                22 views
                0 likes
                Last Post xiinteractive  
                Started by Pattontje, Yesterday, 02:10 PM
                2 responses
                21 views
                0 likes
                Last Post Pattontje  
                Started by flybuzz, 04-21-2024, 04:07 PM
                17 responses
                230 views
                0 likes
                Last Post TradingLoss  
                Working...
                X