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

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 Barry Milan, Today, 10:35 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by WeyldFalcon, 12-10-2020, 06:48 PM
            14 responses
            1,428 views
            0 likes
            Last Post Handclap0241  
            Started by DJ888, Yesterday, 06:09 PM
            2 responses
            9 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            40 views
            0 likes
            Last Post jeronymite  
            Started by bill2023, Today, 08:51 AM
            2 responses
            16 views
            0 likes
            Last Post bill2023  
            Working...
            X