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, 05-11-2026, 05:56 AM
          0 responses
          52 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          29 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          193 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Started by CaptainJack, 04-24-2026, 11:07 PM
          0 responses
          354 views
          0 likes
          Last Post CaptainJack  
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          273 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X