Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawObjects count fails on reload

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

    DrawObjects count fails on reload

    Click image for larger version

Name:	ShowRectangleCount_1.png
Views:	102
Size:	34.9 KB
ID:	1046742






    This bit of code does nothing but print a count of drawing objects on a chart on which there are 2 rectangles.

    When run for the first time, it correctly shows a count of "2" to the output window..

    When you "Reload Ninjascript" , it will display a count of "0" every time.

    When you "Reload All Historical Data" it will behave correctly once again, but then fails when you "Reload Ninjascript".

    Seems likely I'm overlooking something as this behavior would be noticed long ago.

    Help!

    [ATTACH]n1046743[/ATTACH]

    #2
    Hello TikDaddy,

    Thank you for your post.

    This would be expected, we have a note about this in the help guide for DrawObjects: https://ninjatrader.com/support/help...ub=drawobjects

    When reloading NinjaScript, all objects (including manual drawing tools) are reloaded at the same time. There is no guarantee a manually drawn object will be added to the DrawObjects collection before an indicator starts processing data.
    In this case, I wouldn't have a suggestion on how to work around this as this collection is known to load in parallel with your indicator, this can cause the discrepancy you are seeing. In realtime, the collection should update so you could utilize a later time to do this calculation as one way around this, however, if you are specifically trying to do this in historical data I would have no suggestions at having that work as you expect.

    I look forward to being of further assistance.

    Comment


      #3
      Ok.

      Seems to work if I wait 50 ms. after State.Configure

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      558 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 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
      545 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X