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

removing some buttons from chart

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

    removing some buttons from chart

    Hi,
    In NT7, is there a way to selectively remove some of the items on the toolbar list at the top of the chart? Many of them i seldom use, particularly on charts that are running strategies, and it would be useful to trim down the size.
    SS

    #2
    ssylwester, this is not supported.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Hi ssylwester,

      there is a somewhat feasible way to do this. You can remove the chart buttons by key, if you know the name of the control. Say for example, you want to remove the Zoom In and Zoom Out buttons for some reason, add this to your OnStartUp() or Initialize():
      Code:
      if((MessageBox.Show("Remove default buttons from chart?", "Title", MessageBoxButtons.YesNo)) == DialogResult.Yes)
      {	
      	Control[] tsr = ChartControl.Controls.Find("tsrTool", false);
      	if(tsr != null)
      	{	
      		toolStrip = (ToolStrip) tsr[0];
      		if(toolStrip != null)
      		{
      			toolStrip.Items.RemoveByKey("btnZoomIn");
      			toolStrip.Items.RemoveByKey("btnZoomOut");
      		}
      	}			
      }
      Note this is fairly destructive code and the only way I know of to restore the buttons is to recreate the chart. Here is the list (in order) of all the names of the items & buttons on the default chart toolbar. You can remove any using the above method.

      toolStripSeperator9
      btnInstrument
      btnPeriod
      toolStripSeparator1
      btnChartStyle
      btnDraw
      btnZoomIn
      btnZoomOut
      toolStripSeparator2
      btnCursor
      btnDataBox
      toolStripSeparator3
      btnChartTrader
      btnDataSeries
      btnIndicators
      btnStrategies
      btnProperties

      edit: Realizing the logic is backwards if you only want to keep a few, I tried the below code, but it doesn't loop right. Every time you refresh the NinjaScript it would delete one button, instead of all of them at once so the above method is best.
      Code:
      foreach(ToolStripItem t in toolStrip.Items)
      {
      	// only keep the zoom in button for example
      	if(t.Name != "btnZoomIn")
      		toolStrip.Items.RemoveByKey(t.Name);
      }
      Last edited by Dexter; 02-08-2011, 04:21 AM.

      Comment


        #4
        Dexter
        Thanks so much, very much appreciated.

        I am getting an error with
        toolStrip=(ToolStrip) tsr[0];

        NT telling me toolStrip does not exist in current context, err cs0103
        am i missing a declaration somewhere?

        Comment


          #5
          Hi ssylwester,
          Oops, yes! I forgot I had created the variable in my variables section of code. You can simply change it to this:

          ToolStrip toolStrip = (ToolStrip) tsr[0];

          You'll also need to add 'using System.Windows.Forms;' to your using section but it sounds like that's been done. Give that a try and let me know.

          Comment


            #6
            That did the trick, thanks much

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Trader146, Today, 09:17 PM
            0 responses
            2 views
            0 likes
            Last Post Trader146  
            Started by ttrader23, 05-08-2024, 09:04 AM
            9 responses
            43 views
            0 likes
            Last Post ttrader23  
            Started by ZeroKuhl, Yesterday, 04:31 PM
            8 responses
            44 views
            0 likes
            Last Post ZeroKuhl  
            Started by reynoldsn, Today, 07:04 PM
            0 responses
            8 views
            0 likes
            Last Post reynoldsn  
            Started by puapwr, Today, 06:09 PM
            0 responses
            4 views
            0 likes
            Last Post puapwr
            by puapwr
             
            Working...
            X