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

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:	83
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.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Ok.

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

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by pmachiraju, 11-01-2023, 04:46 AM
      8 responses
      148 views
      0 likes
      Last Post rehmans
      by rehmans
       
      Started by mattbsea, Today, 05:44 PM
      0 responses
      5 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      33 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      5 views
      0 likes
      Last Post tkaboris  
      Started by GussJ, 03-04-2020, 03:11 PM
      16 responses
      3,283 views
      0 likes
      Last Post Leafcutter  
      Working...
      X