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 NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          58 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          133 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          73 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          50 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X