Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unique DrawObject Tagging

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

    Unique DrawObject Tagging

    Hello,

    When programmatically drawing objects to a chart, it would be nice if every draw object had a unique ID. So far this can be implemented by using a tag count and increasing its value upon each additional draw object that is created. The problem is that upon refreshing the chart, the tag count variable get's reset. Here's a workaround to run upon startup:

    Code:
    tagCount = 1;
    
    foreach (DrawingTool draw in DrawObjects.ToList())
    {
      if ((draw.Tag).Contains("TextButton")) tagCount++; // tag would be set as "TextButton" + TagCount... "TextButton1"
    }
    The problem with this solution is if all the draw objects are removed from the chart, the tag count remains as is (not really a problem). Also if the tag count is reset but there are tag ID numbers that are higher than the amount of textButton tag IDs, there will be ID overlap (a real problem). So instead, keep track of the highest tag #, independant of the count of tags with "TextButton" ID. I believe this will create unique tags no matter what, however, there may be some tag numbers that are skipped over and unused, but the point is the tags are unique.

    Code:
    tagCount = 1;
    int tempTagCount = 0;
    int highestTempTagCount = 0;
    
    foreach (DrawingTool draw in DrawObjects.ToList())
    {
      if ((draw.Tag).Contains("TextButton"))
      {
        tempTagCount = int.Parse((draw.Tag).Remove(0, 10));
        if (tempTagCount > highestTempTagCount) highestTempTagCount = tempTagCount;
      }
    }
    
    tagCount = highestTempTagCount + 1;


    I also noticed that the count for draw objects using the IDrawingTool appears to be tracked globally. Is there any way an indicator could implement that?

    Honestly, it's not that big of a deal as the indicator has no need to grab object's by ID. With that said, IDs should be unique to every draw object. Perhaps if NT provided an in-house tagging system for indicators to use that would be solid. It's very possible that my solution is not fool proof.

    Thanks
    Unsuitable
    NinjaTrader Ecosystem Vendor - Ocean Trading Indicators

    #2
    Hello Unsuitable,

    I will submit a feature request for the development team to consider assigning IDs to drawing objects.

    Once I have tracking ID for this request I will post in this thread for future reference.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Unsuitable,

      This request is being tracked with ID# SFT-5128.

      As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted in the Release Notes page of the Help Guide.

      Release Notes — https://ninjatrader.com/support/help...ease_notes.htm
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      574 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      332 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X