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 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 jaybedreamin, Today, 05:56 PM
        0 responses
        7 views
        0 likes
        Last Post jaybedreamin  
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        4 views
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        12 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        13 views
        0 likes
        Last Post bltdavid  
        Working...
        X