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 Error SwingRay2

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

    Indicator Error SwingRay2



    this was created by NinjaTrader_Paul

    the idicators both work nicely on the charts

    when i try to use this in strategy i get error I tryed a modified version with a Plot added as well but i cannot get past the error with either

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

    Thanks for help from PaulH or anyone who has worked with this indicator

    #2
    Hello DTSSTS,

    Thanks for your post.

    The SwingRays indicator was converted from a NinjaTrader7 forum thread post. It was, as far as I know, never intended to be used in a strategy, and as it does not use plots, it could not be used in a Strategy Builder strategy.

    What are you specifically trying to do?

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      i created a version with a plot of the break level reference (shown with a green or red Dot - it is the exact level that creates alert messages)

      I wish to use the added plot to then look for Consolidation levels at those level (consolidation areas are shown with the little grey dotted lines at the top and bottom of those area

      So when I find the break level enclosed in the consolidation zone, we are retesting old levels and Trade with the break of the consolidation zone

      so i need the apply to a strategy

      Can also be then used as a stop reference as shown in additional ES image
      Attached Files
      Last edited by DTSSTS; 09-29-2020, 11:58 AM. Reason: Added image

      Comment


        #4
        Hello DTSSTS,

        Thanks for your reply.

        Regarding the errors.

        As the original script was created, we would not hit that sort of issue because it is not usable in the Strategy Builder/Wizard. In the case of this indicator, modifying it to allow use in the Strategy Builder also requires further modifications to address issues that the original script was not designed to deal with. I don't know what those specific issues are as it is beyond our scope to debug the modifications you've made that caused the run-time errors to be produced.

        At this point, I can only recommend debugging using the print statements which I know we have discussed with you before so I won't elaborate on the links.

        As always if you would like something created for you, we can provide a link to 3rd party programmers.

        Paul H.NinjaTrader Customer Service

        Comment


          #5
          thanks again

          Comment


            #6
            Originally posted by DTSSTS View Post
            https://ninjatraderecosystem.com/use...earch=swingray

            this was created by NinjaTrader_Paul

            the idicators both work nicely on the charts

            when i try to use this in strategy i get error I tryed a modified version with a Plot added as well but i cannot get past the error with either

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

            Thanks for help from PaulH or anyone who has worked with this indicator
            Hi Paul,

            Would you perhaps include price value on the unbroken swing rays?

            Thanks.

            Comment


              #7
              Hello aligator,

              Thanks for your post.

              You are welcome to modify the indicator to suit your needs.

              I have not tried this but it may be possible to use the Labeled lines add-on to provide rays with price value.
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Labeled lines add on, is that in the app share

                This is an expansion of the the NinjaTrader Lines Drawing Tool(s) that adds text boxes to each line that will show prices associated with the endpoint or where the line crosses the price scale. Vertical lines will show time stamps. Your own messages can be added to each text box. New settings can be set […]


                if so that would only seem to label manually existing lines (i am probably looking at the wrong add on)

                Comment


                  #9
                  Hello DTSSTS,

                  Thanks for your reply.

                  That is the correct link to what I was referring to.

                  Yes, it does provide manual drawing tools but it also provides Ninjascript access as well.

                  For example Draw.LabeledRay(use the same parameters as for Draw.Ray()).

                  Paul H.NinjaTrader Customer Service

                  Comment


                    #10
                    ah, so Draw.Ray() could possible (MAYBE) be replaced with Draw.LabeledRay to show the values of those line

                    But this still not make those values accessible in a Strategy as they are Still not "Plots"

                    that might very well give aligator what he wants (to see the values on the charts)

                    Thanks

                    Comment


                      #11
                      Hello DTSSTS,

                      Thanks for your post.

                      Correct, they would be part of the draw object and would not be available as a plot.
                      Paul H.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_PaulH View Post
                        Hello aligator,

                        Thanks for your post.

                        You are welcome to modify the indicator to suit your needs.

                        I have not tried this but it may be possible to use the Labeled lines add-on to provide rays with price value.
                        Thank you Paul,

                        LabledLines is a great tool. Also, I have found the following Add-On Horizontal Ray here that would print price text:




                        Both of them work fine for manual. But when simply replacing Draw.Ray with Draw.LabeledLines inside your SwingRay2 indicator Error CS0119 is generated "Draw.LabeledLines .... is a method which is not valid in the given context."

                        Comment


                          #13
                          Hello alligator,

                          Thanks for your reply.

                          I would suggest using Draw.LabeledRay as what you are replacing is already a ray, not a line.

                          I've attached a simple example of using the Draw.LabedRay().

                          Click image for larger version

Name:	DrawLabeledRay.PNG
Views:	384
Size:	87.3 KB
ID:	1120802
                          Paul H.NinjaTrader Customer Service

                          Comment


                            #14
                            PaulH

                            I went back to the original script without my added plot when added to a strategy cause errors in log as well in the OnBarUpdate method

                            i hired a Ninja Lic vendor to look at the code, my added plot did not cause the issue, he sees the issue but says too much needs to be changed for it to work in strategy

                            I cannot see how that could be accurate as there are only 362 lines of code (most of which would not need to be changed)

                            do not know how prints can fix something that will not run, only creates errors in log

                            Attached Files

                            Comment


                              #15
                              Hello DTSSTS,

                              Thanks for your reply.

                              We found a surface level issue when using the original indicator where it would not work properly because a plot was not added, so it would not be compatible with the Strategy Builder. However, once a plot was added, further incompatibilities arise with the script which would need to be addressed before it can work with as you expect.

                              In taking a quick look I noted two things:

                              1) In the modified code, you are assigning the plot within the code block of the Alerts, The Alert code block does not run unless you enable it which you did not do in the strategy builder.

                              2) In the strategy builder, if you check "Plot on chart" for the indicator(and enable the alerts for he indicator) it appears to be functioning (placing trades and showing the indicator and no logged errors. I do still see errors if you do not select "plot on chart".


                              Click image for larger version

Name:	DTSSTS-2.PNG
Views:	385
Size:	62.1 KB
ID:	1120827
                              Paul H.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by elderan, Today, 08:03 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post elderan
                              by elderan
                               
                              Started by algospoke, Today, 06:40 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post algospoke  
                              Started by maybeimnotrader, Today, 05:46 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post maybeimnotrader  
                              Started by quantismo, Today, 05:13 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post quantismo  
                              Started by AttiM, 02-14-2024, 05:20 PM
                              8 responses
                              169 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X