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

Parameter Group and Parameters SubGroup

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

    Parameter Group and Parameters SubGroup

    Hello,

    I want to know how I can add a subgroup of parameters to an existing group, for example:

    Click image for larger version

Name:	Grupo and Subgroup.PNG
Views:	237
Size:	27.2 KB
ID:	1150863

    Thanks,
    wherrera

    #2
    Hello wherrera,

    I'm not aware that it would be possible to modify internal NinjaTrader classes.

    However, you may (or may not) be able to create a custom class type converter to suit your personal needs.


    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello ChelseaB,

      I am creating my own group of parameters and within this group I need to make a subgroup of parameters.

      In addition to the above, I have tested my indicator and have noticed that it only runs when the chart data series is set to 500 days, but this makes NinjaTrader slow

      Thanks,
      Last edited by wherrera; 04-12-2021, 12:33 PM.

      Comment


        #4
        Hello wherrera,

        An expandable class in a category with a unique name may be what you want. This is demonstrated in the ExpandableClassPropertyBrushesExample_NT8 example.

        Does the script have custom logic that requires 500 days?

        If not, use prints to understand why the script is behaving as it is. Start by printing the time of the bar outside of all conditions to ensure every bar of data is being processed.


        Set the chart to a 1 minute chart with 1 day of data to load.

        Save the output to a text file and attach this with your next post.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thank ChlseaB,

          I'm going to try the expandable class.

          Regarding your question:
          Does the script have custom logic that requires 500 days? No, my custom logic does not require 500 days.

          Initially my indicator evaluates if the candle has closed and calculates the ticks and will place it on the candle. I share a piece of code with you.

          protected override void OnBarUpdate()
          {
          if(Close[0] <= Open[0] || Close[0] >= Open[0]) {
          tickLabelPosition = TickSize * DistanceTickLabel;
          double barTicks = double barTicks = (High[0] - Low[0])/TickSize;;

          Draw.Text(this, "tick" + (ShowTicksOnAllBars? CurrentBar: 1), true, barTicks.ToString(), 0, High[0] + tickLabelPosition, 0,
          Brushes.CornflowerBlue, new SimpleFont("Arial",12), TextAlignment.Center,
          Brushes.Transparent, Brushes.Transparent, 0);

          }
          }

          Comment


            #6
            Hello wherrera,

            Did you print the time outside of all conditions?
            Are you seeing the prints?

            Add a print within the action block, is this print appearing?

            What is the value of ShowTicksOnAllBars?

            What is the value of barTicks?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thanks ChelseaB,

              If the chart data series is set 100 days, it shows the following error:

              Indicator 'TradingPlan': Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

              If the chart data series is set 500 days, it shows:

              Click image for larger version  Name:	Output.PNG Views:	0 Size:	4.9 KB ID:	1151214

              Click image for larger version

Name:	Barra.PNG
Views:	213
Size:	2.8 KB
ID:	1151217
              Last edited by wherrera; 04-12-2021, 02:20 PM.

              Comment


                #8
                Hello wherrera,

                Once an error is hit, the script is disabled.

                The error means an invalid index was used. Likely an invalid barsAgo value that was greater than CurrentBar, or an invalid collections index like an invalid plot index.

                See the post linked below about indexing errors.
                https://ninjatrader.com/support/foru...13#post1048513

                What line of code is causing the error?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks ChelseaB,

                  The line of code is causing error is:

                  Draw.Text(this, "tick" + (ShowTicksOnAllBars? CurrentBar: 1), true, barTicks.ToString(), 0, High[0] + tickLabelPosition, 0,
                  Brushes.CornflowerBlue, new SimpleFont("Arial",12), TextAlignment.Center,
                  Brushes.Transparent, Brushes.Transparent, 0);

                  The variable:
                  ShowTicksOnAllBars = false
                  barTicks = number of ticks of the bar
                  tickLabelPosition = 1 ticks above the bar

                  Comment


                    #10
                    Hello wherrera,

                    A value would be an actual number.

                    As an example if the value of CurrentBar is 2, and the value of the barsAgo used is 3, 2 and 3 are the values. barsAgo is greater than CurrentBar and this would cause an error.

                    You've stated: ShowTicksOnAllBars = false. This is actually telling us the value. Thank you.

                    barTicks = number of ticks of the bar. This is pseudo logic and not a value.

                    tickLabelPosition = 1 ticks above the bar. This is pseudo logic and not a value.

                    We are trying to evaluate the condition as the computer does. Without the values, we cannot compute.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Thanks ChelseaB,

                      the value of barTicks = 8 (ticks is shown in the NinjaScript Output image that I shared with you in the previous post)

                      the value of tickLabelPosition = 59.79 (price)

                      Comment


                        #12
                        Hello wherrera,

                        Is 8 larger than CurrentBar? What is CurrentBar?

                        Is 59.79 greater than Close[0]? What is Close[0]?

                        Are you completely sure this is the line causing the error?
                        If that line is commented out, does the error stop?
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          hello ChelseaB,

                          Is 8 larger than CurrentBar? 8 is not CurrentBar, that is number of ticks. What is CurrentBar? CurrentBar is the bar that has recently closed

                          Is 59.79 greater than Close[0]? Yes What is Close[0]? The price of close of the bar

                          Comment


                            #14
                            Hello wherrera,

                            I would like the output from prints. The value of CurrentBar. The values used in this Draw.Text call.

                            Below is a link to a forum post that demonstrates how to use prints to understand behavior.
                            https://ninjatrader.com/support/foru...121#post791121

                            The code below is causing the error and when commented out the error stops, is this correct?:
                            Code:
                            Draw.Text(this, "tick" + (ShowTicksOnAllBars? CurrentBar: 1), true, barTicks.ToString(), 0, High[0] + tickLabelPosition, 0, Brushes.CornflowerBlue, new SimpleFont("Arial",12), TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
                            Print(string.Format("{0} | ShowTicksOnAllBars: {1}, CurrentBar: {2}, barTicks: {3}, High[0]: {4}, tickLabelPosition: {5}, High[0] + tickLabelPosition: {6}", Time[0], ShowTicksOnAllBars, CurrentBar, barTicks, High[0], tickLabelPosition, High[0] + tickLabelPosition ));

                            This print should be placed one line above the Draw.Text() call that is causing the error. If the draw method call is within a condition action block, this print should also be in that action block, one line above where the error is being generated from.

                            What we are trying to find is the invalid index.
                            I personally do not feel that this line is the line causing the error.. However if you are confirming that when this line is commented out the error stops then this would be the line causing the error.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Thank ChelseaB,

                              Let me tell you that the creation of the subgroup of parameters with the example you shared has already worked for me.

                              Also, with the error that was presented to me, I solved it by adding the following:

                              1) BarsRequiredToPlot = 3;
                              2) In the methods I perform this validation
                              if(CurrentBars[0] > BarsRequiredToPlot){

                              }

                              this avoids the problem of: Indicator 'TradingPlan': Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

                              Best Regards.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by GussJ, 03-04-2020, 03:11 PM
                              15 responses
                              3,271 views
                              0 likes
                              Last Post xiinteractive  
                              Started by Tim-c, Today, 02:10 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by Taddypole, Today, 02:47 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post Taddypole  
                              Started by chbruno, 04-24-2024, 04:10 PM
                              4 responses
                              51 views
                              0 likes
                              Last Post chbruno
                              by chbruno
                               
                              Started by TraderG23, 12-08-2023, 07:56 AM
                              10 responses
                              403 views
                              1 like
                              Last Post beobast
                              by beobast
                               
                              Working...
                              X