Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Delete Specific Drawing Objects?

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

    Delete Specific Drawing Objects?

    I can sure use some help on removing drawing objects.

    I'm running a Ninja Script.
    In the script, I have it draw an object when certain conditions are met.
    I want the script to delete the object after other conditions are met.

    I'm using this code:

    if (GetCurrentBid() >= APZ(2, 20).Upper[0]
    && GetCurrentBid() >= Bollinger(2, 14).Upper[0])
    {
    DrawArrowDown("SellArrow" + CurrentBar, false, 0, GetCurrentBid() + 20 * TickSize, Color.Red);
    }

    This draws the arrow perfectly.

    Now, when the condition changes, I want to delete it. I'm using this code:
    if (GetCurrentBid() < APZ(2, 20).Upper[0]
    && GetCurrentBid() < Bollinger(2, 14).Upper[0])
    {
    RemoveDrawObject("SellArrow");
    }

    That's what it shows it the help documentation to delete a drawing object.

    Nothing happens. The arrow stays there. I open up the arrow object on the chart and it shows the name as something like "SellArrow5817". Another sell arrow might show "SellArrow5816". No wonder its not deleting it, it sees the name as something different than "SellArrow".

    Is there any way to prevent Ninja from automatically adding a number to the object so I can delete all past instances of the object when the conditions change?

    I don't want to use RemoveDrawObjects() since it deletes everything (that command works) and I only want it to delete objects with a specific name, like BuyArrow or SellArrow.
    Thanks,
    Joe

    #2
    If you only have 1 arrow at a time, then you can change

    Code:
    DrawArrowDown("SellArrow" + CurrentBar, false, 0, 
                                             GetCurrentBid() + 20 * TickSize, Color.Red);
    to

    Code:
    DrawArrowDown("SellArrow", false, 0, GetCurrentBid() + 20 * TickSize, Color.Red);
    Originally posted by Trade1953 View Post
    I can sure use some help on removing drawing objects.

    I'm running a Ninja Script.
    In the script, I have it draw an object when certain conditions are met.
    I want the script to delete the object after other conditions are met.

    I'm using this code:

    if (GetCurrentBid() >= APZ(2, 20).Upper[0]
    && GetCurrentBid() >= Bollinger(2, 14).Upper[0])
    {
    DrawArrowDown("SellArrow" + CurrentBar, false, 0, GetCurrentBid() + 20 * TickSize, Color.Red);
    }

    This draws the arrow perfectly.

    Now, when the condition changes, I want to delete it. I'm using this code:
    if (GetCurrentBid() < APZ(2, 20).Upper[0]
    && GetCurrentBid() < Bollinger(2, 14).Upper[0])
    {
    RemoveDrawObject("SellArrow");
    }

    That's what it shows it the help documentation to delete a drawing object.

    Nothing happens. The arrow stays there. I open up the arrow object on the chart and it shows the name as something like "SellArrow5817". Another sell arrow might show "SellArrow5816". No wonder its not deleting it, it sees the name as something different than "SellArrow".

    Is there any way to prevent Ninja from automatically adding a number to the object so I can delete all past instances of the object when the conditions change?

    I don't want to use RemoveDrawObjects() since it deletes everything (that command works) and I only want it to delete objects with a specific name, like BuyArrow or SellArrow.
    Thanks,
    Joe

    Comment


      #3
      Hello Joe,
      You have to append the exact tag name while removing the drawobject.

      You have appended the Arrow using the following code.
      Code:
      DrawArrowDown("SellArrow" + CurrentBar, false, 0, GetCurrentBid() + 20 * TickSize, Color.Red);
      Thus while removing the drawobject you have to use that exact tag ("SellArrow" + CurrentBar).

      Since CurrentBar is changing on each bar you have to code it accordingly (like storing the vales in a list array etc).
      JoydeepNinjaTrader Customer Service

      Comment


        #4
        Thanks to both of you!!
        Sledge's method worked great, and I'm sure JoyDeep's will too. It's good to know that you have to use + CurrentBar in the tag name when removing a drawing object that was drawn with + CurrenBar. I was wondering how to store the automatically assigned tag name. Now I know!!
        You guys are the best!!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        637 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        366 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        107 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        569 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        571 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X