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 Mindset, 04-21-2026, 06:46 AM
          0 responses
          87 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          128 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          65 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          117 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          67 views
          0 likes
          Last Post PaulMohn  
          Working...
          X