Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to delete a GLOBAL drawingtool object via script?

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

    How to delete a GLOBAL drawingtool object via script?

    Hi, how to delete a GLOBAL drawingtool object (e.g. HorizontalLine), by its tag and drawn by indicator, via script? RemoveDrawing() does not work if the drawingtool object is global.
    sidlercom80
    NinjaTrader Ecosystem Vendor - Sidi Trading

    #2
    Hello sidlercom80,

    RemoveDrawObject should work with global objects as well, are you drawing it with the script which is trying to remove it? If a different script drew the object then it won't be able to be removed by a separate script.

    Comment


      #3
      Hi Jesse, yes, you are right. The global drawingobject was expropriated by another method. I reassigned the owner correctly when needed, and it seems to work.

      Code:
      DrawingTool.SetDrawingToolCommonValues(line, (lineas IDrawingTool).Tag, (lineas IDrawingTool).IsAutoScale, this, (lineas IDrawingTool).IsGlobalDrawingTool);
      sidlercom80
      NinjaTrader Ecosystem Vendor - Sidi Trading

      Comment


        #4
        Hi,

        Could you please explain a little, what this means:
        The global drawingobject was expropriated by another method. I reassigned the owner correctly when needed, and it seems to work.

        I've drawn some objects.
        I can remove them, unless they are global drawn.

        Whe removing them I use the "@" preceeding the tag name.

        Thanks

        Comment


          #5
          Hi,

          Could you help me?

          How can I remove Global Objects inside my indicator?
          The global objects are drawn inside this same indicator, and after some bars, I want to delete them, but it doesn't work.

          I've trieb using the name with and without the "@".

          Thanks,

          Comment


            #6
            Hello artson,

            RemoveDrawObject can be used to remove a global drawing object. The script that originally draws the object also needs to be the script which removes it. If you are trying to remove an object that another script is drawing that won't work using RemoveDrawObject.

            Here is a quick test you can use to see that it works, if you comment out the RemoveDrawObject line you will see that the object stays on the chart. If you have it uncommented you should see that it draws and then is removed so nothing appears on the chart.

            Code:
            if (CurrentBar == Count - 5)
            {
                Draw.Ray(this, "RayTestGlobal", 50, Low[50], 2, Low[2], true,"");
            }
            if (CurrentBar == Count - 2)
            {
                RemoveDrawObject("RayTestGlobal");
            }

            Comment


              #7
              Thanks,

              It worked!​

              Comment

              Latest Posts

              Collapse

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