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 quantismo, Yesterday, 05:13 PM
      2 responses
      15 views
      0 likes
      Last Post quantismo  
      Started by maybeimnotrader, Yesterday, 05:46 PM
      4 responses
      23 views
      0 likes
      Last Post maybeimnotrader  
      Started by frankthearm, Today, 09:08 AM
      6 responses
      25 views
      0 likes
      Last Post frankthearm  
      Started by adeelshahzad, Today, 03:54 AM
      5 responses
      33 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by stafe, 04-15-2024, 08:34 PM
      7 responses
      32 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X