Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Delete only latest Dot where multiple Dots are drawn

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

    Delete only latest Dot where multiple Dots are drawn

    Hello,

    I have a custom indicator that draws dots under certain conditions. However once the latest dot is drawn, under certain conditions, I need to remove the latest dot drawn. As per the documentation and the example below, I can see RemoveDrawObject() can be used but I would need to create a unique "tag" for each of the dots.

    https://ninjatrader.com/support/foru...-chart?t=18995

    So, how can I just remove the latest dot without affecting the others? or How can I create a unique tag for each of the dots so that when using RemoveDrawObject it only removes the latest dot? An example would be appreciated.

    Thanks in advance!

    #2
    Hello roblogic,

    Thanks for your post.

    As you have observed in order to retain draw objects on the chart you must use unique tag names as otherwise the previously draw object with the same name is automatically removed and replaced by the newest object.

    In your case, you are wanting to both maintain dots as well as occasionally removing the latest drawn dot. A simple approach would be to create a string variable to hold the tag name last used and if your logic dictates removal then to use the string, otherwise, on the next dot the string is overwritten with the newest name. For example:

    if (Your logic to draw a dot)
    {
    Draw.Dot(This, "
    mytag"+CurrentBar, .....);
    lastNameString = "
    mytag"+CurrentBar.Tostring(); // save the tag name into a string for later removal if needed
    }

    if (Your logic to remove the latest dot)
    {
    RemoveDrawObject(lastNameString);
    }


    References:


    Comment


      #3
      Exactly what I needed. Thanks very much!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      52 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      71 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      38 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      99 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      60 views
      0 likes
      Last Post PaulMohn  
      Working...
      X