Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get the number of draw objects on a chart

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

    Get the number of draw objects on a chart

    Looking at the DrawObjects for Developers, I'm confused.
    Under the section" Get the number of draw objects on a chart

    protected override void OnBarUpdate()
    {
    if (DrawObjects.Count == 3)
    {
    // Do something
    }
    }
    ​​
    If you're trying to get the number of draw objects on a chart, why is it set to 3?
    How do you get the number of draw objects on a chart if you don't know how many are on the chart?

    #2
    Hello RJBen,

    Thank you for your post.

    That condition does not state, "DrawObjects.Count is 3," nor does it set the Count equal to 3.
    In C#, == is an equality operator (it checks for equality, it does not assign a value).

    The condition asks "if DrawObjects.Count is 3, then do something".

    https://learn.microsoft.com/en-us/do...lity-operators

    DrawObjects.Count will return the number of objects in the DrawObjects collection.
    Last edited by NinjaTrader_Gaby; 01-28-2025, 07:46 AM.

    Comment


      #3
      Ahhh understood. Thanks Super Moderator Gaby! As long as we're on the subject, what would the syntax be to actually get the count?

      Comment


        #4
        Hello RJBen,

        As per my previous response:

        DrawObjects.Count will return the number of objects in the DrawObjects collection.

        Comment


          #5
          Deleted by User
          Last edited by RJBen; 01-28-2025, 06:50 PM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          80 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          40 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          63 views
          2 likes
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          63 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          54 views
          0 likes
          Last Post CarlTrading  
          Working...
          X