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 habeebft, Today, 07:27 AM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_ChristopherS  
            Started by AveryFlynn, Today, 04:57 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by Max238, Today, 01:28 AM
            4 responses
            37 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by r68cervera, Today, 05:29 AM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by geddyisodin, Today, 05:20 AM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X