Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

problems using RemoveDrawObjects method

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

    problems using RemoveDrawObjects method

    Hi,

    I want to delete all chart objects using a button but I can't delete the lines, text ... using the RemoveDrawObjects or RemoveDrawObject methods. My Button is working and prints all chart objects into the output window but nothing is deleted, why?

    Thanks
    Mario

    Code:
    		private void ButtonClick(object s, EventArgs e) {
    			try{
    					foreach (IDrawObject draw in ChartControl.ChartObjects)
    					{	
    						if(draw.DrawType == DrawType.Line 
    							||draw.DrawType == DrawType.Ray
    							|| draw.DrawType == DrawType.HorizontalLine 
    							||draw.DrawType == DrawType.Ellipse 
    							|| draw.DrawType == DrawType.Rectangle 
    						){
    							RemoveDrawObject(draw.Tag);
    							Print(draw.Tag);
    						}
    					}				
    			}
    			catch(Exception ex){
    				Print("error: " +ex.ToString());
    			}
    			finally{
    				ChartControl.Refresh();
    			}
    		}

    #2
    Hello md236,

    Thank you for your note.

    The drawing objects you are attempting to remove, are these strategy/indicator drawn or manually drawn by the user?

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      the objects are drawn manually, I use a loop to set this objects invisible and back to visible, this works, but not the removing. How can I remove all objects within "ChartControl.ChartObjects"?

      Mario

      Comment


        #4
        Hello md236,

        Manually drawn objects cannot be removed via NinjaScript.

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          ChartControl.ChartObjects is an Array with IDrawObjects, right?
          Can I set this Array empty? Or, if I go to DrawingTools and click "Remove Drawing Objects" this is done by script, or not?

          Comment


            #6
            Hello md236,

            ChartControl.ChartObjects is a collection.

            Setting above to null would not be supported.

            Removing manually drawn objects via a script is not supported.

            Please let us know if you need further assistance.
            Alan P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Hwop38, 05-04-2026, 07:02 PM
            0 responses
            160 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Started by CaptainJack, 04-24-2026, 11:07 PM
            0 responses
            307 views
            0 likes
            Last Post CaptainJack  
            Started by Mindset, 04-21-2026, 06:46 AM
            0 responses
            244 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            348 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            178 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Working...
            X