Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem when set the indicator using the path drawing tool to global drawing object

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

    #16
    Hey Jesse, sorry about that, I had posted the exported strategy. Here's just the .cs file.

    No worries, this doesn't actually create or draw any orders, it's just the logic to draw the Paths in question. This takes the form of 3-day high & 8-day low channels using the Draw.Path() function.
    Attached Files

    Comment


      #17
      Hello mps227,

      I tried the script however I didn't get any errors relating to the object, I did see :

      Strategy 'GlobalPathTestStrategy': Error on calling 'OnBarUpdate' method on bar 9: 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.

      It looks like you have quite a lot of logic and methods left in here which would make it hard to know what may be happening. Have you tried adding a Print near the drawing object to output the values at the time of the problem? If you have the values you could hard code the object in OnBarUpdate as a more simple test without all of the variables and methods.

      I look forward to being of further assistance.

      Comment


        #18
        Hey Jesse,

        I had a chance to spend some time on this tonight. Please find the attached file which simplifies things as much as I can.

        I've removed any added methods & classes. The code will all execute within OnBarUpdate() and consists of a few short lines. I've included some print statements that should assist as well.

        There is one strategy parameter toggle called "Use Path Drawings". When this is set to false it will not call Draw.PathTool(), and the strategy loads just fine.

        When you set this parameter to true, Draw.PathTool() will be called, and you will see the issues I described earlier.

        I load this on 90 bars of a NQ daily chart with Ninjatrader Continuum providing tick level data. It does take a few minutes to load sometimes due to the tick data.
        Attached Files

        Comment


          #19
          Originally posted by NinjaTrader_Jesse View Post
          I look forward to being of further assistance.
          Not sure if this is related.. But could you look into this also..

          1.) Open Blank Chart
          2.) Manual Draw Horizontal Line
          3.) Manually Draw Rectangle
          4.) Manually Draw Triangle
          3.) Manually Draw Path w/4-5 anchors
          4.) Manually Draw Polygon w/4-5 anchors
          4.) Open NT Editor
          5.) Recompile Anything
          6.) Close NT Editor
          7.) Refresh Chart NinjaScript (F5)

          Path & Polygon Tools No Longer Visible!
          Only seems to happen to these 2 tools..



          -=Edge=-
          NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

          Comment


            #20

            Hello mps227,

            I tried the script you provided however so far I have not been able to see any exceptions. I do see some errors due to the error checking not being present in the script for enough data. If you try to load the script and there is not enough tick data you will see an error happening in OnBarUpdate. I otherwise see the prints you added and not any errors. I had used a daily chart and had a 1 minute chart open separately.

            8/13/2021 2:59:59 PM Bar Update Triggered, Bar Number: 9
            Number of High Channel Anchors: 1
            Number of Low Channel Anchors: 1
            Enabling NinjaScript strategy 'GlobalPathTestStrategy/240585534' : On starting a real-time strategy - StartBehavior=ImmediatelySubmit EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=Per entry execution ErrorHandling=Ignore all errors ExitOnSessionClose=False SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=False MaxRestarts=4 in 5 minutes
            Reached State.Realtime
            Have you tried to close all workspaces and work from an empty workspace?

            -=Edge=-, I will try those steps and if I can see an error I will put in a report.

            I look forward to being of further assistance.

            Comment


              #21
              Originally posted by NinjaTrader_Jesse View Post
              -=Edge=-, I will try those steps and if I can see an error I will put in a report.
              There will be no error.. They will just not be visible on the chart..
              Shouldn't take you second to verify.. they're not retaining the Data..

              The path and polygon will still be in the draw objects collection..
              Visibility remains true and all properties remain same, except the Data!


              -=Edge=-
              NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

              Comment


                #22
                Hm, strange Jesse. May I ask how many days you loaded? I've noticed that exceptions may not start on just the first few bars as they load. I always get the exceptions and issues when I load 90 or more though.

                Comment


                  #23
                  Hello mps227,

                  I had tried 30 days as that was all the tick data I could load at the time. Is there a specific date which you are having a problem with? I would suggest trying to simplify your test by reducing the days and amount of data being loaded to see if that relates to the problem at all.

                  I look forward to being of further assistance.

                  Comment


                    #24
                    Hey Jesse,

                    Sorry for the slow reply, hard to find the time for these things. It's interesting, I also see no errors at 30 days. I definitely do at 90 though. Do you mind running it for 90 days?

                    I've performed this test with a new workspace. Any idea why the number of days would matter? 30 days would obviously be far too short to practically utilize.

                    I have noticed the error box tends to pop up around 7/2 & 7/19 of this year, but I have no idea if that's a coincidence or if those dates are precise.

                    Again, I appreciate your help on this Jesse, thanks!

                    Comment


                      #25
                      Hi Jesse,

                      I was looking into this some more this morning and was able to catch the discussed exception being thrown in Visual Studio's debugger. It looks like it's triggering within the foreach loop of the PathTool.cs. Please see attached screenshot. Hopefully this is helpful!
                      Attached Files

                      Comment


                        #26
                        Hello mps227,

                        Have you tried to reload the historical data for that period of time or use a different instrument? That would help to see if the problem relates to your current data in some way. I have been unable to see the error with the provided script. If you find that this relates to data in some way a first step would be to delete the historical data and cache and redownload it to re check the data. If the problem still exists we can have you export the problematic data so we can try the script using that specific time range.

                        For the other steps which -=Edge=- had reported you can track that issue using the following id: 15000

                        I look forward to being of further assistance.

                        Comment


                          #27
                          Hey Jesse,

                          It looks like "Unhandled exception: Collection was modified; enumeration operation may not execute." error was being caused by PathTool.cs modifying the list PathToolSegments while it was still being looped through in the foreach loops previously mentioned. I used PathToolSegments.ToList() to prevent this and it has solved my errors. See attached for reference.

                          Thanks!
                          Attached Files

                          Comment


                            #28
                            Hello mps227,

                            Unfortunately that detail won't help unless we can recreate the error to know why that was happening to begin with. If you have steps related to how you used the script you provided which generates that error we could look further into it. You can also manually edit the path tool code if you find that works to solve the issue on your end.


                            Please let me know if I may be of further assistance.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            576 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            334 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by Mindset, 02-09-2026, 11:44 AM
                            0 responses
                            101 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                            0 responses
                            553 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            551 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X