Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:


    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Exactly what I needed. Thanks very much!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by GussJ, 03-04-2020, 03:11 PM
      11 responses
      3,227 views
      0 likes
      Last Post xiinteractive  
      Started by andrewtrades, Today, 04:57 PM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by chbruno, Today, 04:10 PM
      0 responses
      7 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Started by josh18955, 03-25-2023, 11:16 AM
      6 responses
      440 views
      0 likes
      Last Post Delerium  
      Started by FAQtrader, Today, 03:35 PM
      0 responses
      12 views
      0 likes
      Last Post FAQtrader  
      Working...
      X