Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Removing a Draw Object selectively?

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

    Removing a Draw Object selectively?

    I have an indicator that draws text on every current bar

    Code:
    Draw.Text(this, "MyRating" + CurrentBar, false, MyString.ToString(myDoubleFormat), 0, High[0], +80, Brushes.DeepPink, MyFont, TextAlignment.Center, MyBlue_Brush, Brushes.Black, 100, DashStyleHelper.Dash, 2, false, "");
    But when Ninja draws them, it gives them a different code like MyRating4034, etc.

    How can I write
    Code:
    RemoveDrawObject("MyRating*********");
    to remove all instances beyond a certain bar in the chart.
    Code:
    if (CurrentBar > Count - 20)
    RemoveDrawObject("MyRating**********");​
    doesn't work.


    #2
    Hello davydhnz,

    Thanks for your post.

    Since the Tag name parameter is MyRating" + CurrentBar, each drawing object drawn on the chart will have a unique tag name.

    You would need to loop through the DrawObjects collection to find specific draw objects, get their tag name, and use that tag name when calling RemoveDrawObject().

    See the sample code on the DrawObjects help guide page linked below for how to loop through the DrawObjects collection to find specific draw objects.

    DrawObjects: https://ninjatrader.com/support/help...rawobjects.htm
    RemoveDrawObject: https://ninjatrader.com/support/help...drawobject.htm

    SampleRemoveDrawObjects: https://ninjatrader.com/support/help...s_from_the.htm

    Please let me know if I may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hi Brandon,

      I appreciate your reply, but after going through the Sample Code.
      It only gives a static tag to remove.

      Is there any code for entering a dynamic tag.

      I mean the DrawObjects collection can find specific draw objects and get their tag name,
      but what do I put in e.g. RemoveDrawObject("DrawObjectsCollectionList");
      ?

      Thanks for trying

      Comment


        #4
        Hello davydnhz,

        Thanks for your note.

        Once you loop through the DrawObjects collection to get the Tag name of a drawing object on the chart, you would use that specific draw object Tag when calling RemoveDrawObject() to remove that specific draw object.

        Dynamically removing draw objects using RemoveDrawObject() would require custom logic to store the drawing object's tag names to a list. This would go beyond the support we would be able to provide.

        Please let me know if I may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        571 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        330 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
        549 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        549 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X